I keep getting theses errors in my rsvp form for class even if i type in phone number can someone check out my code and se wha t i have wrong please ?
Notice: Undefined variable: Phone in C:\xampp\htdocs\phptest\process_rsvp.php on line 59
Notice: Undefined variable: Phone in C:\xampp\htdocs\phptest\process_rsvp.php on line 63
Notice: Undefined variable: foodchoice in C:\xampp\htdocs\phptest\process_rsvp.php on line 79
Notice: Undefined variable: comments in C:\xampp\htdocs\phptest\process_rsvp.php on line 83
There were errors in your submission.
Please review the following errors, press the Back button on your browser, and make corrections before re-submitting.
Phone number can only be 10 digits
Phone number must only contain numbers
Please select foodchoice
leave a comment
Having not read your file as it is still pending, the cause of this error is that your form handler is being asked to access the variable $Phone which does not exist…
Why does it not exist?
Because it has not been sent?
Because you have mistyped it? (Variable names are case sensitive : $phone is not the same as $Phone or of course $Ponne)
How can you find out what was sent?
At the top of your form handler add this line;
<?php
var_dump($_POST); // or $_GET if using the GET method.
In the first case go take a careful look at line 59 of process_rsvp.php
here is what I Have for the phone variable
if ($phone ==“”){
$error_msg =“Please enter your phone number” ;
}
if (strlen ($Phone)<>10){
$error_msg []="Phone number can only be 10 digits" ;
}
if(!is_numeric ($Phone)){
$error_msg []="Phone number must only contain numbers" ;
}
i got it all working but now im getting this
Notice: Undefined variable: localhost in C:\xampp\htdocs\phptest\process_rsvp.php on line 151
Notice: Undefined variable: rsvp in C:\xampp\htdocs\phptest\process_rsvp.php on line 154
No database selected
here is how i got it posted conn = mysql_connect($localhost, $dbuser, $dbpass) or die(‘Error connecting to mysql’);
$conn = mysql_connect($localhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname);
As for the undefined variable, you may have these entered as values in a form? But they haven’t being declared yet. (Or before $_POST submit)
You could… at the top of your file, declare them as null or an empty string, e.g. $phone = ‘’;
Or, hide them, as they are only notices, not errors.
At the top of your PHP file, add the following after <?php