Saturday, 24 August 2013

php script not running in WAMP server

php script not running in WAMP server

I have installed WAMP server and using port# 81. All works fine!
http://localhost:81/phpmyadmin/ and even http://localhost:81/?phpinfo=1.
I have placed my website under C:\wamp\www\ folder. On submit button I'm
calling checklogin.php which chwcks for user details from DB, but all i
see is the following script in browser instead of running the php code :(
Need help to resolve this problem!
<?php
$host="http://localhost:81/";
$username="root";
$password="";
$db_name="guru_dakshina";
$tbl_name="members";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and
password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>

No comments:

Post a Comment