I am brand new to the world of php, sql, apache, etc, but I am trying to learn and build this site. But whenever I run this script it will show the page and display the form, but above the form is says:
"Notice: Undefined index: submit in C:\Program Files\Apache Group\Apache2\htdocs\sel1.php3 on line 25"
which is the if($_POST["submit"]) line. Does anyone have any suggestions? If you do, I appreciate it very much as it will probably make my life alot easier.
Thanks!
Amber
<?php
if ($_POST["submit"]) {
// process form
$db = mysql_connect("localhost", "root");
mysql_select_db("evm",$db);
$sql = "INSERT INTO custinfo (name, address1, address2, city, state, zip, email, dname, dob, dod) VALUES ('$name','$add1','$add2','$city','$state','$zip',' $email','$decname','$dob','$dod')";
i changed line 25 to if(isset($_POST['submit'])) and it now longer shows an error.
but when i click submit now, it says i dont have permission to access /.
and it says there's an undefined index and variable in the line with $php_self in it. this line:
It still gives me this message when i click submit:
You don't have permission to access /
Notice: Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in C:/Program Files/Apache Group/Apache2/htdocs/sel1.php on line 43 /sel1.php on this server.
but now it just says parse error where it shouldnt:
$sql = "INSERT INTO custinfo (name, address1, address2, city, state, zip, email, dname, dob, dod) VALUES ('$_POST['name']','$_POST['add1']','$_POST['add2']','$_POST['city']','$_POST['state']','$_POST['zip']','$_POST['email']','$_POST['decname']','$_POST['dob']','$_POST['dod']')";
any suggestions?
this is the error, if it helps:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache Group\Apache2\htdocs\sel1.php on line 31
$sql = "INSERT INTO custinfo (name, address1, address2, city, state, zip, email, dname, dob, dod) VALUES ('{$_POST['name']}','{$_POST['add1']}','{$_POST['add2']}','{$_POST['city']}','{$_POST['state']}','{$_POST['zip']}','{$_POST['email']}','{$_POST['decname']}','{$_POST['dob']}','{$_POST['dod']}')";
you can't call assosicative arrays inside double quotes like this!
you have to either srrounde it with braces (like what I did) or close the quote and . then reopen quotes like this:
PHP Code:
$sql = "INSERT INTO table VALUES ('".$_POST['name']."')";
__________________ PHPSimplicity
We don't need a reason to help people - Zidane [FF9]