php - How to check field value from database -
php - How to check field value from database -
i taking 3 inputs user: username, firstname, email.
i want check if username nowadays in database should check corresponding firstname , email. , if 3 right print message.
html code:
<html> <body> username: <input type="text" name="username"/> firstname: <input type="text" name="name"/> email: <input type="text" name="email"/> </body> </html>
php code:
if(isset($_post['submit'])) { $usrnm=$_post['username']; $name=$_post['name']; $email=$_post['email']; $user_name = "root"; $password = ""; $database = "show_your_talent"; $server = "127.0.0.1"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $res="select username,fname,email reg username='$usrnm'"; $result = mysql_query($res); $count=mysql_num_rows($result); if($count==1) { echo "<script type='text/javascript'> alert('password has been sent email id..')</script>"; } else { echo "<script type='text/javascript'> alert('wrong')</script>"; } } mysql_close($db_handle); }
first please utilize form tag in html method post.then utilize this
if ($db_found) { $name=$_post['name']; $email=$_post['email']; $res="select * reg username='".$usrnm."'"; $res1="select * reg username='".$usrnm."' , fname ='".$name."'"; $res2="select * reg username='".$usrnm."' , fname ='".$name."' , email='".$email."'"; $result = mysql_query($res); $result1= mysql_query($res1); $result2 = mysql_query($res2); $count=mysql_num_rows($result); $count1=mysql_num_rows($result1); $count2=mysql_num_rows($result2); if(($count==1) && ($count1==1) && ($count2==1) ) { echo "<script type='text/javascript'> alert('password has been sent email id..')</script>"; } else { echo "<script type='text/javascript'> alert('wrong')</script>"; } }
php html database
Comments
Post a Comment