Hallo ich habe eine reg.php erstellt. Ich muss die Server-Validierung mit PHP einbeziehen. Ich habe den Code geschrieben und das Java Script in meinem Browser deaktiviert. Aber es zeigt „Sie erfolgreich registriert haben, auch wenn ich irgendwelche field.this nicht geben ist mein Codeserverseitige Validierung
<?php
$hostname = "xxxx";
$username = "xxx";
$password = "xxx";
$dbName = "xxx";
$conn = mysql_connect($hostname,$username,$password) or die(mysql_error());
mysql_select_db($dbName);
if(isset($_POST["submit"]))
{
$username=$_POST['usr'];
$address1=$_POST['addr1'];
$address2=$_POST['addr2'];
$password=$_POST['pswd'];
$email=$_POST['email'];
$errormsg;
if($_POST['usr']=="")
{
$errormsg='enter the name S';
echo $errormsg;
}
elseif(trim($address1)=="")
{
$errormsg="entre the address1 S";
}
elseif(trim($address2)=="")
{
$errormsg="entre the address2 S";
}
elseif(trim($password)=="")
{
$errormsg="entre the password S";
}
elseif(trim($email)=="")
{
$errormessage="enter the email S";
}
mysql_query("INSERT INTO `xxx` (`id` , `Name` , `Address1` , `Address2` , `password` , `email`)
VALUES (
'', '$username', '$address1', '$address2', '$password', '$email'
)")or die(mysql_error()); ;
echo "you have successfully registered ";
}
?>
<html>
<head>
<script type="text/javascript">
function fun()
{
valid=true;
if(document.reg1.usr.value =="")
{
alert("fill the name");
valid=false;
}
if(document.reg1.addr1.value =="")
{
alert("fill the address");
valid=false;
}
if(document.reg1.addr2.value =="")
{
alert("fill the address2");
valid=false;
}
if(document.reg1.pswd.value =="")
{
alert("fill the password");
valid=false;
}
if(document.reg1.email.value =="")
{
alert("fill the email id");
valid=false;
}
return valid;
}
</script>
</head>
<body>
<form name="reg1" action="try.php" method="post">
<table border="0" cellpadding="2" cellspacing="2" width="1000" align="centre">
<tr>
<th>Registration form</th></tr>
<tr><TD align="left">username<TD/>
<TD><input type="text" name= "usr"></TD></tr>
<tr>
<td align="left">address1<td/>
<td><input type="text" name="addr1"></td>
</tr>
<td align="left" width="15%">address2<td/>
<td><input type="text" name=addr2></td></tr>
<tr>
<td align="left">password<td/>
<td><input type="password" name="pswd"></td>
</tr>
<tr>
<td align="left">emailaddress<td/>
<td><input type="text" name="email"></td>
</tr>
<tr>
<tr><TD></TD>
<td><input type="submit" name="submit" value="submit" onclick="return fun();"></td></tr>
</table>
</form>
</body>
</html>
kann jemand helfen plz ?????
Injektionsanfälligkeit? wo: - D +1 für das –
Es gibt nur einen Punkt, wo es irgendwelche SQL gibt, so ist es leicht zu finden (vor allem mit den Informationen in der verknüpften Frage) – Quentin
Hallo danke für Ihren wertvollen Vorschlag .. Ich habe alles außer der Query gemacht . aber ich bekomme immer noch dasselbe –