CBEP
03-22-2007, 11:48 PM
I have been having trouble inserting data into my GoDaddy mysql database using a simple php interface (see code below). (I have a more complex php and MySQL that a webmaster friend of mine setup for my website too). The code seems fine, no error comes up when submitting the data, no login error, etc. but when we check the MySQL database it always stays empty. No data is entered.
You can check out the more detailed php my friend made
www.ahs1997.com/alumni.php
www.ahs1197.com/submit.php
Any ideas of what might be going on? GoDaddy offered no help whatsever, they said it was beyond theire technical expertise!
Thanks for any help!
(www.ahs1997.com/enter-data.com)
<?php
$hostname = "h50mysql7.secureserver.net";
$db_user = "atwaterhigh";
$db_password = omitted;
$db_table = "rsvp";
$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($db_table,$db);
?>
<html>
<head>
<title>How To Insert Data Into MySQL db using form in php</title>
</head>
<body>
How To Insert Data Into MySQL db using form in php<hr>
<?php
if (isset($_REQUEST['Submit']))
{
# THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE
$sql = "INSERT INTO $db_table(user_name,user_email) values ('$user_name','$user_email')";
$result = mysql_query($sql ,$db);
echo "Thank you, Your information has been entered into our database";
}
else
{
?>
<form method="post" action="">
Name:<br>
<input type="text" name="user_name">
<br>
Email: <br>
<input type="text" name="user_email">
<br><br>
<input type="submit" name="Submit" value="Submit">
</form>
<?php
}
?>
<body>
</body>
</html>
You can check out the more detailed php my friend made
www.ahs1997.com/alumni.php
www.ahs1197.com/submit.php
Any ideas of what might be going on? GoDaddy offered no help whatsever, they said it was beyond theire technical expertise!
Thanks for any help!
(www.ahs1997.com/enter-data.com)
<?php
$hostname = "h50mysql7.secureserver.net";
$db_user = "atwaterhigh";
$db_password = omitted;
$db_table = "rsvp";
$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($db_table,$db);
?>
<html>
<head>
<title>How To Insert Data Into MySQL db using form in php</title>
</head>
<body>
How To Insert Data Into MySQL db using form in php<hr>
<?php
if (isset($_REQUEST['Submit']))
{
# THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE
$sql = "INSERT INTO $db_table(user_name,user_email) values ('$user_name','$user_email')";
$result = mysql_query($sql ,$db);
echo "Thank you, Your information has been entered into our database";
}
else
{
?>
<form method="post" action="">
Name:<br>
<input type="text" name="user_name">
<br>
Email: <br>
<input type="text" name="user_email">
<br><br>
<input type="submit" name="Submit" value="Submit">
</form>
<?php
}
?>
<body>
</body>
</html>