Я не так хорош в PHP, так что вы можете сказать мне, что здесь не так?
Происходит то, что я получаю синтаксическую ошибку, и это сводит меня с ума. Я пытаюсь запустить скрипт, но он дает мне только синтаксическую ошибку. Я перепробовал все, что знаю, но не могу понять, что не так.
Ошибка разбора: синтаксическая ошибка, неожиданный ‘{‘ в C: \ wamp \ www \ als \ register.php в строке 15
Вот мой код:
<?php
error_reporting (E_ALL ^ E_NOTICE);
if ( $_POST['register']) {
$getuser = $_POST['user'];
$getemail = $_POST['email'];
$getpass = $_POST['pass'];
$getretypepass = $_POST['retypepass'];
if($getuser) {
if($getemail) {
if($getpass){
if($getretypepass) {
if( $getpass === $getretypepass ) {
if ( (strlen($getemail) >= 6 ) && (strstr($getmeial, "@")) && (strstr($getmeial, ".")){
require("./config.php");
$query = mysql_query("SELECT * FROM strizon WHERE user='$getuser'");
$numrows = mysql_num_rows($query);
if ($numrows == 0) {
$query = mysql_query("SELECT * FROM strizon WHERE email='$getemail'");
$numrows = mysql_num_rows($query);
if ($numrows == 0) {
$pass = md5(md5("Jmsad31".$pass."JU821Dkmal"));
$date = date("F d, Y");
$code = md5(rand());
mysql_query("INSERT INTO strizon VALUES ('', '$getuser', '$getpass', '$getemail, '0', '$code', '$date')");$query = mysql_query ("SELECT * FROM strizon WHERE user='$getuser'");
$numrows = mysql_num_rows($query);
if($numrows == 1) {
$site = "http://localhost/als";
$webmaster = "Strizon Account Activiation <[email protected]>";
$headers = "From: $webmaster";
$subject = "Activate your Strizon Account";
$message = "Thank you so much for registering with Strizon. Please click the link below to activate your account.\n";
$message .= "$site/activeate?user=$getuser&code=$code\n";
$message .= "Again, thank you!\n";
$message .= "Sincerely\n";
$message .= "The Strizon Team";
if(mail($getemail, $subject, $message, $headers)) {
echo("You have not successfully been registered! You must activate your account from the activation link sent to <b>$getemail</b>");
$getuser = "";
$getemail = "";
}
else {
echo("An error has occured. Your activation email could not be sent!");
}
}
else{
echo("An error has occured, and your account was not created.");
}
}
else {
echo("There is already a user with that email address. Please choose another email address!");
}}
else {
echo("There is already a user with that username. Please choose another username!");
}mysql_close();
}
else {
echo("You must enter an valid email address to register!");
}
}
else {
echo ("Your passwords did not match!");
}
}
else {
echo("You must retype your password to register!")
}
}
else {
echo("You must enter a password to register!");
}
}
else {
echo ("You must enter an email address to register!");
}
}
<pre>
else {
echo "You must enter a username to register.";
}
</pre>
$form = "<form action='' method='post'>
<br>
<input type='text' name='user' value='$getuser' placeholder='Username'>
<br>
<input type='email' name='email' value='$getemail' placeholder='Email Address'>
<br>
<input type='password' name='pass' placeholder='Password'>
<br>
<input type='password' name='retypepass' placeholder='Retype Password'>
<br>
<input type='submit' name='register' value='Register'>
";
echo($form);
?>
Спасибо за любую помощь 🙂
Прежде всего это грязный стиль кодирования.
Следующие ошибки у вас есть:
1) вы пропустили закрытие (
в этой строке:
if ( (strlen($getemail) >= 6 ) && (strstr($getmeial, "@")) && (strstr($getmeial, ".")){
2) вы пропустили ;
в этой строке:
echo("You must retype your password to register!")
3) ты тоже пропустил закрытие }
первого оператора if.
Вы должны были закрыть if-statement
в этой строке:
if ( (strlen($getemail) >= 6 ) && (strstr($getmeial, "@")) && (strstr($getmeial, ".")){
Рабочий код:
<?php
error_reporting (E_ALL ^ E_NOTICE);
if ( $_POST['register']) {
$getuser = $_POST['user'];
$getemail = $_POST['email'];
$getpass = $_POST['pass'];
$getretypepass = $_POST['retypepass'];
if($getuser) {
if($getemail) {
if($getpass){
if($getretypepass) {
if( $getpass === $getretypepass ) {
if ( (strlen($getemail) >= 6 ) && (strstr($getmeial, "@")) && (strstr($getmeial, "."))){
require("./config.php");
$query = mysql_query("SELECT * FROM strizon WHERE user='$getuser'");
$numrows = mysql_num_rows($query);
if ($numrows == 0) {
$query = mysql_query("SELECT * FROM strizon WHERE email='$getemail'");
$numrows = mysql_num_rows($query);
if ($numrows == 0) {
$pass = md5(md5("Jmsad31".$pass."JU821Dkmal"));
$date = date("F d, Y");
$code = md5(rand());
mysql_query("INSERT INTO strizon VALUES ('', '$getuser', '$getpass', '$getemail, '0', '$code', '$date')");$query = mysql_query ("SELECT * FROM strizon WHERE user='$getuser'");
$numrows = mysql_num_rows($query);
if($numrows == 1) {
$site = "http://localhost/als";
$webmaster = "Strizon Account Activiation <[email protected]>";
$headers = "From: $webmaster";
$subject = "Activate your Strizon Account";
$message = "Thank you so much for registering with Strizon. Please click the link below to activate your account.\n";
$message .= "$site/activeate?user=$getuser&code=$code\n";
$message .= "Again, thank you!\n";
$message .= "Sincerely\n";
$message .= "The Strizon Team";
if(mail($getemail, $subject, $message, $headers)) {
echo("You have not successfully been registered! You must activate your account from the activation link sent to <b>$getemail</b>");
$getuser = "";
$getemail = "";
}
else {
echo("An error has occured. Your activation email could not be sent!");
}
}
else{
echo("An error has occured, and your account was not created.");
}
}
else {
echo("There is already a user with that email address. Please choose another email address!");
}}
else {
echo("There is already a user with that username. Please choose another username!");
}mysql_close();
}
else {
echo("You must enter an valid email address to register!");
}
}
else {
echo ("Your passwords did not match!");
}
}
else {
echo("You must retype your password to register!")
}
}
else {
echo("You must enter a password to register!");
}
}
else {
echo ("You must enter an email address to register!");
}
}
<pre>
else {
echo "You must enter a username to register.";
}
</pre>
$form = "<form action='' method='post'>
<br>
<input type='text' name='user' value='$getuser' placeholder='Username'>
<br>
<input type='email' name='email' value='$getemail' placeholder='Email Address'>
<br>
<input type='password' name='pass' placeholder='Password'>
<br>
<input type='password' name='retypepass' placeholder='Retype Password'>
<br>
<input type='submit' name='register' value='Register'>
";
echo($form);
?>