简单的HTML表单数据收集

时间:2015-12-26 16:03:07

标签: php html

我对HTML语言比较陌生,但设法创建一个简单的HTML表单,指向一个PHP文件来收集响应数据。但是,PHP脚本在提交时没有收集任何内容,但没有抛出错误。我想知道是否有人能够在我的代码中发现错误,或者他们是否有更优雅的解决方案来收集回复。

HTML:

@echo off&cls

::The Path of your Videos files

set "$VideoPath=C:\FolderwithVideos"

::If you want your Code in this BAT remove the REMs Below :

rem dir "%$VideoPath%" /O:S /b /-p /o:gn > "C:\result.txt"
rem call replacer.bat result.txt ".mp4" ""

setlocal enabledelayedexpansion
set /a $Count=1
set "$Timer=00:00:00"


(for /f "delims=" %%a in (result.txt) do (
  call:getVideolength "%%a.mp4"
  for /f "delims=" %%x in ('cscript //nologo getvideolength.vbs') do (
       call:SumTime !$Timer! %%x
       for /f "delims=" %%y in ('cscript //nologo SumTime.vbs') do set "$NewTimer=%%y"
       echo !$Count!
       echo !$Timer!,000 --^> !$NewTimer!,000
       echo %%a
       Set $Timer=!$NewTimer!
  )
  set /a $Count+=1
  echo.
))>Output.srt

echo Done !!!
type Output.srt
pause
exit/b

:GetVideoLength
(echo dim objShell
echo dim objFolder
echo dim objFolderItem
echo set objShell = CreateObject("shell.application"^)
echo set objFolder = objShell.NameSpace("%$videoPath%"^)
echo set objFolderItem = objFolder.ParseName(%1^)
echo dim objInfo
echo objInfo = objFolder.GetDetailsOf(objFolderItem, 27^)
echo wscript.echo objinfo)>GetVideoLength.vbs
exit/b


:SumTime
echo wscript.echo FormatDateTime(CDate("%1"^) + CDate("%2"^),3^) >SumTime.vbs
exit/b

PHP:

<form action="form_save.php" method="POST">
  <fieldset align="left">
  <legend>Demographics</legend>
  <p><i>To be completed by participant</i></p>
  <table>
    <tr>
    <td>Name:</td><td><input type="text" name="name" size="40" /></td>
    </tr>

    <tr>
    <td>Age:</td><td><input type="text" name="age" size="40" /></td>
    </tr>

    <tr>
    <td>Sex:</td>
    <td>
        <br>
        <input type="radio" name="sex" value="male" checked>Male
        <br>
        <input type="radio" name="sex" value="female" checked>Female
        <br>
        <input type="radio" name="sex" value="other">Other</td>
    </tr>

    <tr>
    <td>Ethnicity:</td>
    <td>
        <br>
        <input type="radio" name="ethnicity" value="Hispanic/Latino" checked>Hispanic/Latino
        <br>
        <input type="radio" name="ethnicity" value="Not Hispanic/Latino" checked>Not Hispanic/Latino
        <br>
    </td>
    </tr>

    <tr>
    <td>Race :</td>
    <td>
      <br>
      <input type="radio" name="race" value="African American" checked>African American
      <br>
      <input type="radio" name="race" value="Asian" checked>Asian
      <br>
      <input type="radio" name="race" value="American Indian / Native Alaskan" checked>American Indian / Native Alaskan
      <br>
      <input type="radio" name="race" value="Caucasian" checked>Caucasian
      <br>
      <input type="radio" name="race" value="Native Hawaiian or Other Pacific Islander" checked>Native Hawaiian or Other Pacific Islander
      <br>
      <input type="radio" name="race" value="other">Other
    </td>
    </tr>
    <tr>
    <td><input type="submit" value="Submit"></td>
    </tr>
</form>

我还应该注意,PHP代码指向一个.csv文件,该文件也托管在这两个文件所在的服务器上。

1 个答案:

答案 0 :(得分:2)

要获取POST数据,请在接收PHP文档中执行以下操作:

$name = $_POST['name'];
$age = $_POST['age'];
$sex = $_POST['sex'];
etc.

现在他们在变量中,你可以使用它们。