Jump to content

Recommended Posts

predict.php

<body>
<!--contact form start here-->
 <h1>Smart Medical Application</h1>
<div class="contact"> 
<div class="contact-top">
<h2>PREDICTION - Enter Your Symptom</h2>
    </div>
<div class="fiel">
<form>
<form action="what.php" method = "post" >
<input placeholder="First Symptom" name = "first" type="text" >
<input placeholder="Second Symptom" name = "second" type="text" >
<input placeholder="Third Symptom" name = "third" type="text" >
</form>
</div>
<div class="send">
<form>
  <input type="submit" name="submit"  value="PREDICT!"/>
   </form>
<br></br>
<a href="../main/main.php"><button>BACK</button></a>
</div>
</div> 
<div class="copyright">
<p>© 2015 All rights reserved | MannRazz Dev Team</p>
</div> 
<!--contact form end here-->
</body>
 
 
 
 
what.php
<?php
 
$first = $_POST['first'];
$second = $_POST['second'];
 
$first = stripcslashes($first);
$second = stripcslashes($second);
$first = mysql_real_escape_string($first);
$second = mysql_real_escape_string($second);
 
mysql_connect("localhost", "root", "");
mysql_select_db("predict");
 
$result = mysql_query("SELECT * FROM predict WHERE first = '$first' AND second = '$second'");
or die ("Failed to query database".mysql_error());
 
$row = mysql_fetch_array($result);
if ($row['first'] == $first && $row['second'] == $second) 
{
echo "LOGIN SUCCES WELCOME ".$row['first'];
}
else
{
"Failed to login";
}
?>
 
 
****
- i want to conect with the database when both of the query is correct.. and when both is correct... i wanted to call and display the third data from the database (etc : welcome, SAM - SAM is the data that i wanted to call)
 
but it seem doesnt working at the moments... any help will be much appreciated....thanz
Edited by Ch0cu3r
Link to comment
https://forums.phpfreaks.com/topic/299738-cant-connect-with-database/
Share on other sites

The database connection needs to be made before you can use mysql_real_escape_string().

http://php.net/manual/en/function.mysql-real-escape-string.php

 

Also, there is a syntax error here:

$result = mysql_query("SELECT * FROM predict WHERE first = '$first' AND second = '$second'");
or die ("Failed to query database".mysql_error());
 
There shouldn't be a semi-colon before "or".
$result = mysql_query("SELECT * FROM predict WHERE first = '$first' AND second = '$second'") 
or die ("Failed to query database".mysql_error());
 
 
And in case you're not aware, mysql_* functions have been deprecated and will be removed in PHP 7. More information can be found here:
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.