I have a .php
file which has so far two functions. Here is the file :
<?php
function Register()
{
$Name=$_POST["NameTxt"];
$Email=$_POST["EmailTxt"] ;
$Pass=$_POST["PasswordTxt"];
$RePass = $_POST["RePasswordTxt"];
if (!preg_match("/^[a-zA-Z\- ]*$/",$Name) or empty($Name)) {
header("Location: http://localhost/tutorial/Mdaeg-login.html");
}
elseif (!filter_var($Email, FILTER_VALIDATE_EMAIL)or empty($Email) or empty($Pass)) {
header("Location: http://localhost/tutorial/Mdaeg-login.html");
}
elseif($Pass!=$RePass)
{
header("Location: http://localhost/tutorial/Mdaeg-login.html");
}
$connect=mysql_connect("localhost" , "root" , "Password") or die(mysql_error());
mysql_select_db("Database", $connect);
$read="select Email from users where Email='$Email'";
$result=mysql_query($read,$connect);
$rowcount=mysql_num_rows($result);
if($rowcount==0)
{
$sql="INSERT INTO Users (Name,Email,Password) VALUES ('$Name','$Email','$Pass')";
mysql_query($sql,$connect);
}
mysql_close($connect);
header("Location: http://localhost/tutorial/Mdaeg-login.html");
}
function Login()
{
$Email=$_POST["EmailLogin"] ;
$Pass=$_POST["PassLogin"];
$connect=mysql_connect("localhost" , "root" , "kamal3007") or die(mysql_error());
mysql_select_db("Mdaeg", $connect);
$read="select Email,Password from users where Email='$Email'";
$result=mysql_query($read,$connect);
$rowcount=mysql_num_rows($result);
mysql_close($connect);
if($rowcount==1)
{
header("Location: http://localhost/tutorial/Profile.html");
}
}
?>
I have two questions about this code. First,is there any possible way to call a .php function from javascript? Second question, in the second function I'll get the email and the password from the database, but how can I read each column separately so that I can check the password? Thank you in advance. :)