burntheblobs Posted October 26, 2008 Share Posted October 26, 2008 For some reason this script returns two extra numbers (even though the form only submits letters) when I am returning the $value variable in the section that processes the form. The form is only four fields long, but when I echo $value, it shows the four values from the form plus two more values. I'm a little confused. Hopefully someone can help. <?php if ($action != processform) { dateForm(); } if ($action == processform) { $badform = "no"; foreach ($_POST as $field => $value) { if ($value == "") { echo "<font color='red'>You have not filled in a "; convertLabel($field); echo "!<br></font>"; $badform = "yes"; } echo "$value"; if (!ereg("^[A-Za-z '-]{0,50}$",$value) ) { echo "<font color='red'>"; convertLabel($field); echo " has invalid characters!<br></font>"; $badform = "yes"; } } } if ($badform == "yes") { dateForm(); } if ($badform == "no") { echo "Success!"; } function dateForm() { echo "<b> <font size='4'>Add A Date!</font><br><br>"; $labels = array ("Date_Name" => "Date's Name", "Date_School" => "Date's School", "Date_City" => "Date's City", "Date_State" => "Date's State"); echo "<form action='newdate.php?action=processform' method='POST'>\n"; foreach ($labels as $field => $label) { $value = $_POST[$field]; echo "$label <br><input type='text' name='$field' value='$value' size='50' maxlength '50'>"; if ($field == "Date_School") { echo " </b><font size='2'><a href='newschool.php'>New School?</a></font><b>"; } echo "<br><br>\n"; } echo "<input type='image' SRC='images/adddatebutton.png' ALT='Submit button'></form>"; } function convertLabel($field) { if ($field == "Date_Name") { $label = "Date Name"; } if ($field == "Date_School") { $label = "Date School"; } if ($field == "Date_City") { $label = "Date City"; } if ($field == "Date_State") { $label = "Date State"; } echo "$label"; } ?> Link to comment https://forums.phpfreaks.com/topic/130138-solved-extra-values-being-retrieved-from-post-form/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 26, 2008 Share Posted October 26, 2008 They are probably from your image submit button - http://us.php.net/manual/en/faq.html.php#faq.html.form-image Link to comment https://forums.phpfreaks.com/topic/130138-solved-extra-values-being-retrieved-from-post-form/#findComment-674830 Share on other sites More sharing options...
burntheblobs Posted October 26, 2008 Author Share Posted October 26, 2008 You are correct. Thank you! Link to comment https://forums.phpfreaks.com/topic/130138-solved-extra-values-being-retrieved-from-post-form/#findComment-674863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.