Jump to content

[SOLVED] User Signup Script Problem


discoDrive

Recommended Posts

Hello there,

 

I have been dabbling with a user signup form, just to make sure I am familiar with the code. When it is working I will adapt it to fit my website design, but I'm having a problem with it at the moment.

 

The code below is giving me some problems because it gets as far as creating the query, but it will not execute it. If anybody can see the problem at a glance please let me know as it is causing me to tear my hair out. If you need any more info, I'll post anything up. Thankyou for your time.

 


<html><head><title>Adding a User</title></head><body>
<?php 
$self = $_SERVER['PHP_SELF'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$username = $_POST['username'];
$password = $_POST['password'];

if ( ( !$firstname ) or ( !$lastname )
				or ( !$username ) or ( !$password ) )
{

$form ="Please fill in the following:";
$form.="<form action=\"$self\"";
$form.=" method=\"POST\">First Name: ";
$form.="<input type=\"text\" name=\"firstname\"";
$form.=" value=\"$firstname\"> <br>Last Name: ";
$form.="<input type=\"text\" name=\"lastname\"";
$form.=" value=\"$lastname\"> <br>User Name: ";
$form.="<input type=\"text\" name=\"username\"";
$form.=" value=\"$username\"> <br>Password: ";
$form.="<input type=\"text\" name=\"password\"";
$form.=" value=\"$password\"><br>";
$form.="<input type=\"submit\" value=\"Submit\">";
$form.="</form>";
echo( $form ) ;
}

else
{ $conn = @mysql_connect( "localhost", "root", "discosucks" )
or die("Could not connect to MySQL");
$db = @mysql_select_db( "noodlenews", $conn)
or die("Could not find database");
$sql = "insert into members
(firstname,lastname,username,password) values
(\"$firstname\",\"$lastname\",\"$username\"
password(\"$password\") )";
$result = @mysql_query( $sql, $conn)
or die("Could not execute query");
if( $result ) { echo ( "New user $username added" ); }
}
?>

Link to comment
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.