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