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
https://forums.phpfreaks.com/topic/79337-solved-user-signup-script-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.