Add User script "Could not execute query"
Posted on
16th Feb 2014 07:03 pm by
admin
This should be an easy script but I can't get it to run. Can someone please help me?
<html><head><title>Adding a User</title></head>
<body>
<?php
$self = $_SERVER['PHP_SELF'];
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$user_email = $_POST['useremail'];
if( (!$first_name) or (!$last_name) or (!$user_email) )
{
$form ="Please enter all new user details...";
$form.="<form action="$self"";
$form.=" method="post">First Name: ";
$form.="<input type="text" name="firstname"";
$form.=" value="$first_name">
Last Name: ";
$form.="<input type="text" name="lastname"";
$form.=" value="$last_name">
Email: ";
$form.="<input type="text" name="useremail"";
$form.=" value="$user_email">
";
$form.="<input type="submit" value="Submit">";
$form.="</form>";
echo($form);
}
else
{
#connect to MySQL
$conn = @mysql_connect("localhost","xxxx","xxxx")
or die("Could not connect to MySQL");
#select a database
$db = @mysql_select_db("xxxx",$conn)
or die("Could not select database");
#create the SQL query
$sql = "insert into tablename (firstname, lastname, useremail)
values ("$first_name",'"$last_name","$user_email" )";
#execute the query
$result = @mysql_query($sql,$conn)
or die("Could not execute query");
if($result)
{ echo("New user $user_email added"); }
}
?>
</body></html>
No comments posted yet
Your Answer:
Login to answer
331
7
Other forums
INSERT for date range
Hi all
I have the following table
Code: [Select] `date` date
`day` int(2)
`
Read from forum
Haven't written anything forever and I would like to get back.
What I'm trying to do is getting t
PHP not creating file.
Its supposed to create a .ini file in the /scriptfiles/users/ with the name they entered into the fi
Can't seem to capture a variable in a chained select
I'm *this* close to having a chained select running but for some reason it doesn't seem to be pickin
Form errors in an array
I'm processing a form and putting the errors in an array. empty($errors) doesn't seem to do the tric
WHYISNT THIS MYSQL STATEMNT NOT WORKING? (php)
caps because its absolutely rediculous.
i dontunderstand why its not working. there is a column c
login form can you find my error?
registrationform.php seems fine send data to registration.php
registration.php seems fine checks
Last Weeks sDate and eDate.
sDate - Start Date
eDate - End Date
I need to pull two dates for "Last Week" whi
List/Menu Box
On an edit page when you want something to select what a user has previously selected from the datab
Sort Alternative/bi-monthly
Hi all,
Am going mad trying to get something to work.
I'm creating a CMS for a magazi