The below coding, includes two function in this program, one function inserts the dealers into database "insert_dealer" before which the a function checks if the particular dealer has already created an account, to do this, i have used function "check_email".
Now my problem is
echo "<script>
alert('Username already exist');
</script>"
under the check_user function the alert works, after which the dealer is inserted into db, where
echo "<script>
alert('Dealer's profile has been added. Login credentials are sent to their mail id.');
</script>
the alert does not work
THE NEW DEALER IS ADDED INTO DB, BUT THE ALERT ALONE IS NOT DISPLAYED..
please check the code below and suggest your ideas.
<?
include_once('config.php');
function insert_dealer($title, $fname, $lname, $email, $phone, $token)
{
mysql_query("SET NAMES utf8");
{ $user_query = "INSERT INTO dealer_tbl(title, firstname, lastname, email, phone, password, date_created, time_created)
VALUES ('$title','$fname','$lname','$email','$phone',password('$token'), CURDATE(), CURTIME())";
}
$user_result = mysql_query($user_query);
// echo $user_query;
if (!$user_result)
{
die('Error on query: ' . mysql_error());
}
else
{
echo "<script>
alert('Dealer's profile has been added. Login credentials are sent to their mail id.');
window.location = './dealer_portal.php'</script>";
/*header('Location: dealer_portal.php?status=1&uname='.$email.'&pwd='.$token);*/
}
}
function check_email($title, $fname, $lname, $email, $phone, $token)
{
mysql_query("SET NAMES utf8");
{ $dealer_query = "SELECT * FROM `dealer_tbl` WHERE `email` = '". $email ."'";
}
$result = mysql_query($dealer_query);
$num_rows = mysql_num_rows($result);
// echo $user_query;
if ($num_rows > 0)
{
echo "<script>
alert('Username already exist');
window.location = './dealer_portal.php'</script>";
return 0;
}else{
insert_dealer($title, $fname, $lname, $email, $phone, $token);
return 1;
}
}
?>
Quotes are placing problem, try something like this:
echo "<script>
alert('Dealer\'s profile has been added. Login credentials are sent to their mail id.');
</script>";
else you need to concatenate your strings & variables.
0 comments:
Post a Comment