<?php
session_start();
include_once "connect.php";
$fullName = $_POST['fullname'];
$userName = $_POST['username'];
$emailAdd = $_POST['email'];
$passWord = $_POST['password'];
$query = mysql_query("SELECT * FROM users where USERNAME = '$username' ");
$result = mysql_fetch_array($query);
if($fullName == "")
{
?>
<script>
alert("Full Name is required!");
window.location.href = "registeruser.php";
</script>
<?php
}
else
{
if ($userName == "")
{
?>
<script>
alert("Invalid username!");
window.location.href = "registeruser.php";
</script>
<?php
}
else
{
if($userName == $result['USERNAME'])
{
?>
<script>
alert("Username already exists!");
window.location.href = "registeruser.php";
</script>
<?php
}
else
{
if ($emailAdd == $result['EMAIL'])
{
?>
<script>
alert("Email address is required!");
window.location.href = "registeruser.php";
</script>
<?php
}
else
{
if ($passWord == "")
{
?>
<script>
alert("Username is required!");
window.location.href = "registeruser.php";
</script>
<?php
}
else
{
if($_POST['password']==$_POST['confirmpass'])
{
mysql_query("INSERT INTO users (FULLNAME, USERNAME, EMAIL, PASSWORD)
VALUES ('$fullName', '$userName', '$emailAdd', '$passWord')");
mysql_close();
?>
<script>
alert("Registered Successfully!");
window.location.href = "index.php";
</script>
<?php
}
else
{
?>
<script>
alert("Password and Confirm Password do not match");
window.location.href = "registeruser.php";
</script>
<?php
}
}
}
}
}
}
?>
Es funktioniert gut. Aber das Problem ist: das Alert-Fenster zeigt auf eine andere Webseite und nicht innerhalb der Webseite Es ist in Ordnung, aber es sieht schrecklich aus, den Benutzer zu einer anderen Webseite zu leiten, ohne Inhalt dort zu haben. Wenn Sie mir bitte helfen könnten, dies zu beheben und das JavaScript-Warnfenster nur auf derselben Webseite anzeigen zu lassen. Eigentlich habe ich einige Lösungen wie diese versucht ..JavaScript Alert Fenster Redirects zu einer anderen Webseite
if($fullName == "")
{
echo '<script>';
echo 'alert("Full Name is required!")';
echo 'window.location.href = "registeruser.php"';
echo '</script>';
}
versuchen, eine '/', bevor Sie den 'registereduser.php' oder legen Sie den genauen Pfad mit Domain-Namen setzen. – roullie
Vollständigen Pfad zu 'echo 'hinzufügen window.location.href =" registeruser.php "';' –
Nein. Es funktioniert nicht. – monsteruniversity0908