Jump to content

Recommended Posts

I have a script that is supposed to allow a user to add their details to a members table in the database.

 

It acts as if the user has been added to the database by stating the thank you message, but there is no entry into the database.

 

I can connect to the database and have another script running OK that allows me to view all of the information in the members table with a loop (this data was entered using php my admin's GUI).

 

Here is the script that is supposed to add the member.

 

Any help would be greatly appreciated.

 

<?php

error_reporting(-1);

$user_name = "root";
$password = "";
$database = "test";
$server = "localhost";

$db_handle = mysql_connect($server, $user_name, $password);

$db_found = mysql_select_db($database, $db_handle);

if ($db_found)
{
	$SQL = "INSERT INTO members (fname, sname, email, password, gender) VALUES ('$_POST[fname]','$_POST[sname]','$_POST[email]','$_POST[password]','$_POST[gender]')";
	$result = mysql_query($SQL);

	mysql_close($db_handle);

	print "Thanks for joining us ".$_POST['fname'].".";
}
else
{
	print "Database NOT Found";
	mysql_close($db_handle);
}

?>

Link to comment
https://forums.phpfreaks.com/topic/221387-trying-to-add-data-to-a-mysql-table/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.