I'm designing a web front-end for a mysql database using php. First, let me be clear that I do not write php . Right now, it is hosted on my localhost. I'm using wamp and apache and wampserver are both running/online.
I have my php code divided into two pages, which I have stored in the www folder of wampserver, as instructed.
Page 1: phptest.php contains just HTML code to allow the input of form data:
<html>
<form action="insert.php" method="post">
Last Name: <input type="text" name="last"><br>
First Name: <input type="text" name="first"><br>
Street Address: <input type="text" name="address"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip Code: <input type="text" name="zip"><br>
Birth Date: <input type="text" name="birthdate"><br>
Phone: <input type="text" name="phone"><br>
Email: <input type="text" name="email"><br>
<input type="Submit">
</form>
</html>
Page 2: insert.php is SUPPOSED to insert the data into the mysql database hosted on my localhost, but does not. the html page submits, but the data doesn't go anywhere.
<?php
$username="root@localhost";
$database="mountainview3";
$last=$_POST['last'];
$first=$_POST['first'];
$address=$_POST['address'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$birthdate=$_POST['birthdate'];
$phone=$_POST['phone'];
$email=$_POST['email'];
mysql_connect(localhost,$username);
@mysql_select_db($database) or die("Unable to select database");
$query="INSERT INTO PERSON_T(LAST_NAME, FIRST_NAME, STREET_ADDRESS, CITY, STATE, ZIP, BIRTH_DATE, PHONE, EMAIL) VALUES ('$last', '$first', '$address', '$state','$zip', '$birthdate', '$phone', '$email')";
mysql_query($query);
mysql_close()
?>
honestly, I can't get the second file to do ANYTHING really. I commented out the majority of it to test and used echo $last; to see if I could get a response and got nothing.
@Dan-- thanks for your response-- the record I submitted still does not show up in my database, although presumably the code is somewhat better because Eclipse color-codes it
I have my php code divided into two pages, which I have stored in the www folder of wampserver, as instructed.
Page 1: phptest.php contains just HTML code to allow the input of form data:
<html>
<form action="insert.php" method="post">
Last Name: <input type="text" name="last"><br>
First Name: <input type="text" name="first"><br>
Street Address: <input type="text" name="address"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip Code: <input type="text" name="zip"><br>
Birth Date: <input type="text" name="birthdate"><br>
Phone: <input type="text" name="phone"><br>
Email: <input type="text" name="email"><br>
<input type="Submit">
</form>
</html>
Page 2: insert.php is SUPPOSED to insert the data into the mysql database hosted on my localhost, but does not. the html page submits, but the data doesn't go anywhere.
<?php
$username="root@localhost";
$database="mountainview3";
$last=$_POST['last'];
$first=$_POST['first'];
$address=$_POST['address'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$birthdate=$_POST['birthdate'];
$phone=$_POST['phone'];
$email=$_POST['email'];
mysql_connect(localhost,$username);
@mysql_select_db($database) or die("Unable to select database");
$query="INSERT INTO PERSON_T(LAST_NAME, FIRST_NAME, STREET_ADDRESS, CITY, STATE, ZIP, BIRTH_DATE, PHONE, EMAIL) VALUES ('$last', '$first', '$address', '$state','$zip', '$birthdate', '$phone', '$email')";
mysql_query($query);
mysql_close()
?>
honestly, I can't get the second file to do ANYTHING really. I commented out the majority of it to test and used echo $last; to see if I could get a response and got nothing.
@Dan-- thanks for your response-- the record I submitted still does not show up in my database, although presumably the code is somewhat better because Eclipse color-codes it