Currently I'm developing contact us form what is my question when i run that script on localhost, the name field and email field inside error has appeared like:
(<br /><b>Notice</b>: Undefined index: name in <b>E:\wamp\www\rrr\btech开发者_如何学运维\index.php</b> on line <b>49</b><br />)
(<br /><b>Notice</b>: Undefined index: email in <b>E:\wamp\www\rrr\btech\index.php</b> on line <b>49</b><br />)
after click the submit the response will be undefined syntax error.
<tr>
<td valign="bottom"><span class="contactus-txt">
<input name="textfield222" type="text" class="contact-field" style="width:125px;" value="<?php echo $_GET['name'];?>" />
</span></td>
<td valign="bottom"><span class="contactus-txt">
<input name="textfield2222" type="text" class="contact-field" style="width:125px;" value="<?php echo $_GET['Email-Id'];?>"/>
</span></td>
</tr>
I used that html code.
Can any one tell me what mistake I made?
Here goes the right way:
<?php
$FORM['name'] = "";
$FORM['Email-Id'] = "";
if (isset($_GET['name'])) $FORM['name'] = htmlspecialchars($_GET['name']);
if (isset($_GET['Email-Id'])) $FORM['Email-Id'] = htmlspecialchars($_GET['Email-Id']);
?>
<tr>
<td valign="bottom"><span class="contactus-txt">
<input name="textfield222" type="text" class="contact-field" style="width:125px;" value="<?php echo $FORM['name'];?>" />
</span></td>
<td valign="bottom"><span class="contactus-txt">
<input name="textfield2222" type="text" class="contact-field" style="width:125px;" value="<?php echo $FORM['Email-Id'];?>"/>
</span></td>
All variables should be initialized before use.
Your question is not all that clear. I assume you have an action for this form and either a post or get method?
From the two inputs I can see, your values should appear in the $_POST variable as $_POST['textfield222'] and $_POST['textfield2222'] for the post method and $_GET['textfield222'] and $_GET['textfield2222'] if the form is using the get method.
As a general rule, never trust user input - validate the forms data before using it.
I hope this is of use.
精彩评论