Jump to content

Register Page


kokeroulis

Recommended Posts

HelloI want to create a page in which someone can register a new account.I use the following code but in the line 30 it says that there is the following error "Fatal error: Can't use function return value in write context in /var/www/register/register.php on line 30".Please can you help me?

<html><body><form method="post" action="register.php">Username<br>  <br>  <input name="username"><br>  <br>Password<br>  <br>  <input name="password" type="password"><br>  <br>E-Mail<br>  <br>  <input name="email"><br>  <br><input name="submit" type="submit"><br></form><?php$con = mysql_connect("localhost","root","root");if (!$con)  echo mysql_error();mysql_select_db("register", $con);$dedomena = mysql_query("INSERT INTO register (username, password, email)VALUES ('$_POST[username]', '$_POST[password]', '$_POST[email]')");if (gettype($_POST["username"]) != NULL && gettype($_POST["password"]) != NULL && gettype($_POST["email"]) != NULL && (isset($_POST["submit"]))  {   $dedomena;  echo "register has been completed";  }elseif (gettype($_POST['username']) = NULL or gettype($_POST['password']) = NULL or gettype($_POST['email']) = NULL)  echo "One or more fields are empty";?></body></html>

Link to comment
Share on other sites

first you say$dedomena = mysql_query(..something..);when u do this, the query runs already, not when u say $dedomena; a few lines furtheralso just checking if they're not empty in the first if() would probably be cleaner, and for security u should use mysql_real_escape_string() to post varsa way u should do it instead could be:

if (!empty($_POST["username"]) && !empty($_POST["password"]) && !empty($_POST["email"]) && isset($_POST["submit"])){ 	$dedomena = mysql_query("INSERT INTO register (username, password, email)VALUES ('".mysql_real_escape_string($_POST['username'])."', '".mysql_real_escape_string($_POST['password'])."', '".mysql_real_escape_string($_POST['email'])."')"); 	echo "register has been completed";}else  echo "One or more fields are empty";

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...