milov.nl

Interaction design • webdevelopment • web art • photography

milov.nl : forum : coding : 'What's wrong with this script?'

What's wrong with this script? Ayt, 050423 13:28
Can you see anything wrong with this script?



<?php

mysql_connect("myhost","myuser","mypass");
mysql_select_db("mydatabase");

$password1 = $_POST["password1"];
$password2 = $_POST["password2"];

echo "$password1<br>";

$username = $_POST["username"];

echo "$username";

$query = "SELECT * FROM `table` WHERE username = '$username' ";

$result = mysql_query($query);
$num = mysql_num_rows($result);

if ($num == 0)
{
$pass = 1;

}
else
{
echo "An user <b>$username</b> already exists. Sorry";
$pass = 0;
}

$query = "INSERT INTO 'table'('username', 'password') VALUES ('$username', '$password1')";

if ($password1 == $password2 && $password1 != "" && $password1 != " " && $pass == 1)
{
mysql_query($query);
echo "Query OK, The user $username has been added to the database.";
}
else
{
echo "The passwords do not match or the delivered password was an empty string or a space character.";
}

?>

 
YYYMKDCCLXXXVII.dsl.saunalahti.fi
Re: What's wrong with this script? Milo, 050423 14:19
Depends on what you want it to do, I guess...
milov.demon.nl
Re: What's wrong with this script? Ayt, 050424 09:05
It is meant to register an user to a MySQL database.

Can you see anything wrong with it?
YYYMKDCCLXXXVII.dsl.saunalahti.fi
Re: What's wrong with this script? Calm_Pear, 050424 11:57
Do you get any error messages?
h103091.upc-h.chello.nl
Re: What's wrong with this script? Ayt, 050427 14:24
No, I couldn't.

Fortunately I solved the problem (it was a syntax error in the query) but I forgot to tell it here.

Thank you for your help.

-Ayt-
YYYMKDCCLXXXVII.dsl.saunalahti.fi
Pages: 1