Jump to content

Small Error - checking username


master82

Recommended Posts

Here is my register code - I get the data from a form (POST command).

But im getting this error message:

[b]Fatal error[/b]: Only variables can be passed by reference in [b]site root here\addnewuser.php [/b]on line [b]18[/b]

that being:

[code]
end("Username already in use - Try another");
[/code]

Full script:

[code]
<?php

session_start();

$ip = ($_SERVER['HTTP_X_FORWARDED_FOR'])
    ?  $_SERVER['HTTP_X_FORWARDED_FOR']
    :  $_SERVER['REMOTE_ADDR'];

require_once("dbconfig.php");

if($_POST['username'])
{
$username=$_POST['username'];
$username=str_replace(array("<", ">"), array("&lt;", "&gt;"), $username);
$qry=mysql_query("SELECT * FROM users WHERE username='{$username}'",$conn);
if(mysql_num_rows($qry))
{
end("Username already in use - Try another");
}
else if($_POST['password'] != $_POST['verify'])
{
end("The passwords did not match - Try again");
}
else
{
mysql_query("INSERT INTO users (HIDDEN FIELDS) VALUES(HIDDEN VALUES)", $conn);

header("Location: login.php");
}
}
else
{
end("Something went wrong - Try again");
}
?>
[/code]

Thankd in advance for any help you can give...
Link to comment
https://forums.phpfreaks.com/topic/17873-small-error-checking-username/
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.