problem in sign up code

1 replies
i created a website when i click register it says parse error: syntax error, unexpected end of file here is the code
<?php




$mysql_hostname = "localhost";mt_rand()));
$mysql_user = "root";

$mysql_password = "";

$mysql_database = "cryptothrift";

$prefix = "";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");

mysql_select_db($mysql_database, $bd) or die("Could not select database");


$urldecode = $_SERVER['REQUEST_URI'];

$url1=explode("=",$urldecode);
$page=$url1[1];

if ($page=="register")
{

header('Content-Type: application/json');

$email=$_REQUEST['email'];
$username=$_REQUEST['username'];

//$varpwd=mot de passe généré



function random_readable_pwd($length=10)
{

// the wordlist from which the password gets generated
// (change them as you like)
$words = 'AbbyMallard,AbigailGabble,AbisMal,Abu,Adella,TheA gent,AgentWendyPleakley,Akela,AltheAlligator,Alada r,Aladdin,AlamedaSlim,AlanaDale,Alana,Alcmene,Alic e,AmeliaGabble,AmosSlade,Amphitryon,AnastasiaTrema ine,Anda,Andrina,Angelique,AngusMacBadger';

// Split by ",":
$words = explode(',', $words);
if (count($words) == 0){ die('Wordlist is empty!'); }

// Add words while password is smaller than the given length
$pwd = '';

while (strlen($pwd) < $length){
$r = mt_rand(0, count($words)-1);
$pwd .= $words[$r];
}

$num = mt_rand(1, 99);
if ($length > 2){
$pwd = substr($pwd,0,$length-strlen($num)).$num;
} else {
$pwd = substr($pwd, 0, $length);
}

$pass_length = strlen($pwd);
$random_position = rand(0,$pass_length);

$syms = "!@#$%^&*()-+?";
$int = rand(0,51);

$rand_char = $syms[$int];

$pwd = substr_replace($pwd, $rand_char, $random_position, 0);

return $pwd;
}

$password=random_readable_pwd();
echo($password);





echo ($password);



//requete pour vérifier l'existance de mail



$requeteinsertion='insert INTO users (username,password) VALUES('.$username.','.$password.')';

if(mysql_query($requeteinsertion))
{


//envoi de mail qui contient le mot de passe

$to=$email;
$subject="registeration to crptothrift";

$message="thank you for registering to cryptothrift your password is ".$pass;

$headers=NULL;

mail($to, $subject, $message, $headers);




echo"succes";





}
else
{

echo"failure";


}
?>
#code #problem #sign
  • Profile picture of the author geekSoftware
    In the attachment(because for unknown reason I can't submit here the code) you've fixed version of your code and more readable version. I would suggest to you using MySQLi instead of MySQL.
    {{ DiscussionBoard.errors[9821742].message }}

Trending Topics