PDA

View Full Version : if(isset($_POST['checkme'])) is not being executed in the Dreamweaver please help me out


swetha123
10-02-2008, 11:19 AM
hello to every one,

I am new to this thread and Dream weaver
i am using the dream weaver to build my web site

please help me out ,

my question is

when i click on the Sign in image which is having the name as checkme it should display me the appropriate message according to conditions as mentioned and i called the php code with this
sign in image name i.e, if(isset($_POST['checkme'])) from here it is not displaying the messages


hope u understand my problem ,,

here is my original code




<html>
<head>
<title>Untitled Document</title>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript">

<!--
function FP_goToURL(url) {//v1.0
window.location=url;
}
// -->

</script>
</head>

<?php
function connect()
{
$dbhost='localhost';
$dbuser='root';
$dbpass='swetha';
$conn= mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'.mysql_error());
$dbname='abc';
mysql_select_db($dbname);
return $conn;
}
function IsEmpty($cuser,$cpass)
{
$str1=strlen($cuser);
$str2=strlen($cpass);
$nRes=min($str1,$str2);
if ($nRes==0)
{
echo " <font size='4' face='Garamond' color='white'><b> Missing user Id / Password!! </b></font> </br>";
}
return $nRes;
}
?>

<body bgcolor="#0a1936">
<form name="myform" method="post" action="<?php $_SERVER['PHP_SELF']?>" >
<div style="text-align:center;">

<table align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="765">
<table width="70%" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#0a1936" >
<img width="370px" height="54px" align="left" src="abc.jpg"/>
<table align="right" >
<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
<tr>
<td bgcolor="#0a1936">
<img height="29px" width="73px" src="retailersbl.jpg" onclick="FP_goToURL(/*href*/'retailers1.php')"/>
<img width="15px" height="27px" src="line1bl.jpg"/>
<img height="28px" width="128px" src="abouthus.jpg"/>
<img width="15px" height="27px" src="line1bl.jpg"/>
<img height="29px" width="109px" src="contactusbl.jpg"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td >
<img src="top1.jpg" width="805px" height="20px"/>
</td>
</tr>
<tr>
<td>
<table bgcolor="#000000" align="left" cellpadding="0" cellspacing="0">
<tr>
<td >
<img src="rborder2.JPG" width="20px" height="420px"/>
</td>
<td width="763" >
<table height="420" width="760" cellpadding="0" cellspacing="0">
<tr>
<td align="center" width="85%" >
<img src="hdr_signin1.PNG" style="float: right; z-index: 2; position: absolute; top: 128px; left: 158px;" height="31" width="79" alt="Sign In"/>

<img src="access_acc2.PNG" style="float: right; z-index: 2; position: absolute; top: 173px; left: 163px;" height="42" width="321" alt="Access Account"/>

<img src="your_e-mail_address1.PNG" style="float: right; z-index: 2; position: absolute; top: 230px; left: 162px; " height="22" width="131" alt="Email Id"/>

<input type="text" name="cname" style="float: right; z-index: 2; position: absolute; top: 230px; left: 305px; right: 304px; height: 14px; width: 177px; bottom: 303px;"/>

<img src="password1.PNG" style="float: right; z-index: 2; position: absolute; top: 260px; left: 162px; " height="22" width="88" alt="Password"/>

<input type="text" name="cpass" style="float: right; z-index: 2; position: absolute; top: 260px; left: 305px; right: 304px; height: 14px; width: 177px;"/>

<input type="image" name="checkme" src="sign_in_off1.PNG" alt="image alt text" style="float: right; z-index: 2; position: absolute; top: 249px; left: 492px; right: 213px;"/>

<?php
if(isset($_POST['checkme']))
{
$cusername=$_POST['cname'];
$cpassword=$_POST['cpass'];
$check=IsEmpty($cusername,$cpassword);
if ($check>0)
{
$c=connect();
$query = "SELECT user_id,password FROM users where user_id='".$cusername."' AND password='".$cpassword."'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

if (mysql_num_rows($result) > 0)
{
echo "<font size='4' face='Garamond' color='white'><b>Succefully Logged In.. </b></font> </br>";
}

else
{
echo "<font size='4' face='Garamond' color='white'><b>Oouchh.. you failed to Log In </b></font> </br>";
}
}
}
?>


<label id="Label1" style="float: right; z-index: 2; position: absolute; top: 321px; left: 162px; width: 114px; right: 723px;"><font color="white"> Forgot Password : </font> </label>

<a href="forgot.php" style="float: right; z-index: 2; position: absolute; top: 319px; left: 260px; width: 110px;" > <h3>Click here </h3></a>

<img src="new_account1.PNG" style="float: right; z-index: 2; position: absolute; top: 367px; left: 163px; " height="42" width="321" alt="New Account"/>
<img src="create_new_account_off1.PNG" style="float: right; z-index: 2; position: absolute; top: 430px; left: 163px; " height="32" width="176" alt="Creat New Account"/>
</td>
<td width="15%" valign="top" >
<img src='logo.JPG'/> </td>
</tr>
</table>
</td>
<td>
<img height="420px" width="20px" src="rborder2.JPG"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<img src="top1.jpg" width="805px" height="20px"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right">
<img src="inc.gif"/>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

rattlsnak
10-02-2008, 06:23 PM
hello to every one,

hope u understand my problem ,,

if(isset($_POST['checkme']))


$query = "SELECT user_id,password FROM users where user_id='".$cusername."' AND password='".$cpassword."'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

if (mysql_num_rows($result) > 0)
{


Not exactly sure what you mean, but first off, the if(isset($_POST) function is used to check to see if a $_POST is valid, but you havent set that up yet, are you trying to use a session for that? I dont see where you started or named a session.

Second, after you send a query to the database, you have to put it somewhere, or tell it how to return it back to you, like using:
mysql_fetch_array();

So, yours would look like this:


$query="SELECT * FROM users WHERE user_id='$cusername' and password='$cpassword'";
$result=mysql_query($query);
$rowAccount=mysql_fetch_array($result);

THird, why are you using a . and quotes around your database fields?

You will have to change a few variables, but that should get you started. Once you verify/validate the user, then you can start a session, check the session to see who is logged in, and then redirect or display whatever you want based on that.

swetha123
10-13-2008, 08:22 AM
hello,
can any one tell me how to remove the empty spaces

it is showing me the empty spaces when i view the page in the explorer or any browser please tell where iam doing wrong and tell me how to remove the empty spaces

it is showing spaces near four corners of the borders in my code



<table align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="766">
<table cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#0a1936" >
<img width="370px" height="54px" align="left" src="/abclogobl.jpg"/>
<table align="right" >
<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
<tr>
<td bgcolor="#0a1936">
<img src="/retailersbl.jpg" width="79" height="30" onclick="FP_goToURL('retailer.php')"/>
<img width="15px" height="27px" src="/line1bl.jpg"/>
<img src="/abouthakmanbl.jpg" height="30" width="136" onclick="FP_goToURL('about.php')"/>
<img width="15px" height="27px" src="/line1bl.jpg"/>
<img height="29px" width="109px" src="/contactusbl.jpg" onclick="FP_goToURL('contactus.php')"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td >
<img src="/top1.jpg" width="805px" height="20px"/>
</td>
</tr>
<tr>
<td cellpadding="0" cellspacing="0">
<table bgcolor="#000000" align="left" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="/rborder2.JPG" width="20px" height="420px"/>
</td>
<td bgcolor="#000000" align="center" width="763" cellpadding="0" cellspacing="0">
<font face="Monotype Corsiva" size="+3"color="#CCCCCC"> Welcome To abc & CO </font>
</td>
<td width="15" valign="top">
<img src="/abc.JPG"/>
</td>
<td>
<img height="420px" width="20px" src="/rborder2.JPG"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<img src="/top1.jpg" width="805px" height="20px"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right">
<img src="/inc.gif"/>
</td>
</tr>
</table>



please help me out, waiting for the reply

thanks in advance

davidj
10-13-2008, 06:23 PM
Not exactly sure what you mean, but first off, the if(isset($_POST) function is used to check to see if a $_POST is valid, but you havent set that up yet, are you trying to use a session for that? I dont see where you started or named a session.


this is valid...

if(isset($_POST)


remember that $_POST is a super global array variable and can be treated as a normal array variable. All his test is doing is checking if it contains a value.

also


after you send a query to the database, you have to put it somewhere, or tell it how to return it back to you, like using:



he is using ...


if (mysql_num_rows($result) > 0)



swetha123

contact me on MSN messenger