Previous in Forum: Project Suggestion   Next in Forum: Losing that Pesky "Insert" Function
Close
Close
Close
2 comments
Rate Comments: Nested
Participant

Join Date: Feb 2014
Posts: 1

PHP Program Execution

02/05/2014 6:31 AM

Dear Sir,

I am a beginner in PHP programming and stuck up executing couple of programs. May I request you, help me identifying my mistake?

Regards

Sunita

Program Login.php

<form action="checklogin.php" method="post">
User name : <input type="text" name="name"><br><br>
Passward : <input type="password" name="pwd"><br><br>
<input type="submit">
</form>

====

Program 2-check log in

<?php
$a=$_POST['name'];
$b=$_POST['pwd'];
//echo $a;
//echo $b;
$host="localhost";
$user="root";
$db="test";

$con=mysql_connect("$host","$user","");
mysql_select_db("db",$con);
$query="select * from login where user_name='$a' and pass='$b'";


$sql=mysql_query($query);
echo $sql;
$n=mysql_num_rows($sql);
echo $n

Request your help

Regards

Sunita

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru

Join Date: Mar 2007
Location: by the beach in Florida
Posts: 33392
Good Answers: 1817
#1

Re: PHP Program Execution

02/05/2014 9:25 AM
__________________
All living things seek to control their own destiny....this is the purpose of life
Register to Reply
Participant

Join Date: Feb 2014
Posts: 1
#2

Re: PHP Program Execution

02/12/2014 11:22 AM

There is an error at: mysql_select_db($db, $con);

i would advice you use an error handler if statement.i.e

if(!mysql_select_db($db,$con)){

mysql_error();

}

Register to Reply
Register to Reply 2 comments

Previous in Forum: Project Suggestion   Next in Forum: Losing that Pesky "Insert" Function

Advertisement