MySQL Forums
Forum List  »  PHP

PHP mySQL not working!!!!!
Posted by: Brandon Nelson
Date: April 13, 2015 08:33PM

OK, I have a HTML form and a PHP script to connect to my DB and insert the record. I have tried everything I can think of and Google and Youtube and others..... I can NOT figure this out.... PLEASE HELP.... I keep getting Server error when I run the form. Below is my code.

This is my HTML Form

<?php include ('includes/connect.php'); ?>
<form name="registration" method="post" action="registration.php">
<!-- we will create registration.php after registration.html -->
<center><font color="yellow">First Name:</font></center>
<center><input type="text" name="fname" value=""></center><p></p>
<center><font color="yellow">Last Name:</font><center><input type="text" name="lname" value=""></center><p></p>
<center><font color="yellow">State:</font><center>
<Select type="text" name="state" value=""></center>
<option value="AL">AL</option>
<option value="AK">AK</option>
</select>

<p></p>
<center><font color="yellow">Email Address:</font><center><input type="text" name="email" value=""></center><p></p>
<center><input type="submit" name="submit" value="submit"></center>
</form>


My Connection strings

//Define VARS
$dbhost = 'I ASSUME MY DB IP WOULD GO HERE'; //This is from GoDaddy
$dbuser = 'USERNAME';//This is the username I setup
$dbpassword = 'PASSWORD';//This is is PW I setup
$db = 'DB';//This is the DB I'm connecting to

$conn = mysql_connect($dbhost,$dbuser,$dbpassword);
mysql_select_db($db);



This is my page where the form is sending the info too //registration.php

<?php
include ('includes/connect.php');

$fname = $_POST['fname'];
$lname = $_POST['lname'];
$state = $_POST['state'];
$email = $_POST['email'];

if(!$_POST['submit']) {
echo "Please fill out the form";
header('Location: index.html');
} else {
mysql_query = "INSERT INTO users (`ID`, `First_Name`,`Last_Name`,`State`,`Email_Address`) VALUES (NULL, '$fname', '$lname', '$state', '$email')" or die mysql_error();

echo "Thank you for registering, be on the lookout for updates!";
header('Location: index.php');
}


?>

Options: ReplyQuote


Subject
Written By
Posted
PHP mySQL not working!!!!!
April 13, 2015 08:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.