user login script problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kandarpmistry
Forum Newbie
Posts: 8
Joined: Sat Feb 13, 2010 11:28 pm

user login script problem

Post by kandarpmistry »

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<body background="querybackground.jpg">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="font-family:times; color:black; font-size:20px; text-align:center">CUSTOMER LOGIN</p>
<p style= text-align:"center">
<?php
function validateOnSubmit()
{
$errs= True;
if (strlen($Ctrid) < 6 || strlen($Ctrid) > 12 && $Ctrid != NULL)
{
$errs = False;
echo "alert('Please enter user id of length greater than or equal to 6 characters and less than or equal to 12 characters')";
}
if (strlen($pwd) < 6 || strlen($pwd) > 12 && $pwd != NULL)
{
$errs = False;
echo "alert('Please enter password of length greater than or equal to 6 characters and less than or equal to 12 characters')";
}
if ($Ctrid == NULL && $pwd == NULL)
{
$errs = False;
echo "alert('Please fill the required categories before submitting')";
}
return $errs;
}
echo "<form name="translation_login_input" onsubmit="return validateOnSubmit()" action="translationorder.htm" method="get">
<table>
<tr>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">Customer id</p></td>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">:</p></td>
<td><input $Ctrid type="text" name="Customerid" value="" size="20">
<br></td>
</tr>
<tr>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">Password</p></td>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">:</p></td>
<td><input $pwd type="password" name="Password" value="" size="20">
<br></td>
</tr>
</table>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</p>
<p style="font-family:times; color:black; font-size:20px; text-align:center">If you are a new customer, <a href="newcustomerlogin.htm">please follow this link...</a></p>
"
?>
</body>
</html>

NOTE: It shows the following error: "PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in F:\Kandarp\testing\DEASICREATIONSWEBSITE\translationlogin.php on line 30 " PLEASE HELP
User avatar
Weiry
Forum Contributor
Posts: 323
Joined: Wed Sep 09, 2009 5:55 am
Location: Australia

Re: user login script problem

Post by Weiry »

Please wrap your code using the php or code tags..

your problem is here:

Code: Select all

echo "<form name="translation_login_input" onsubmit="return validateOnSubmit()" action="translationorder.htm" method="get">
<table>
<tr>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">Customer id</p></td>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">:</p></td>
<td><input $Ctrid type="text" name="Customerid" value="" size="20">
<br></td>
</tr>
<tr>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">Password</p></td>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">:</p></td>
<td><input $pwd type="password" name="Password" value="" size="20">
<br></td>
</tr>
</table>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</p>
<p style="font-family:times; color:black; font-size:20px; text-align:center">If you are a new customer, <a href="newcustomerlogin.htm">please follow this link...</a></p>
"
you can either end the php tag or you can use the correct quotation with the echo quotations.

Example..

Code: Select all

 
echo "<form name='translation_login_input' onsubmit='return validateOnSubmit()' action='translationorder.htm' method='get'>"; // correct
echo '<form name="translation_login_input" onsubmit="return validateOnSubmit()" action="translationorder.htm" method="get">'; // correct
 
echo "<form name="translation_login_input" onsubmit="return validateOnSubmit()" action="translationorder.htm" method="get">"; // incorrect
 
or you could use the following where you end the php tag before you print out the HTML

Code: Select all

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<body background="querybackground.jpg">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="font-family:times; color:black; font-size:20px; text-align:center">CUSTOMER LOGIN</p>
<p style= text-align:"center">
<?php
function validateOnSubmit()
{
$errs= True;
if (strlen($Ctrid) < 6 || strlen($Ctrid) > 12 && $Ctrid != NULL)
{
$errs = False;
echo "alert('Please enter user id of length greater than or equal to 6 characters and less than or equal to 12 characters')";
}
if (strlen($pwd) < 6 || strlen($pwd) > 12 && $pwd != NULL)
{
$errs = False;
echo "alert('Please enter password of length greater than or equal to 6 characters and less than or equal to 12 characters')";
}
if ($Ctrid == NULL && $pwd == NULL)
{
$errs = False;
echo "alert('Please fill the required categories before submitting')";
}
return $errs;
}
?>
<form name="translation_login_input" onsubmit="return validateOnSubmit()" action="translationorder.htm" method="get">
<table>
<tr>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">Customer id</p></td>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">:</p></td>
<td><input type="text" name="Customerid" value="" size="20">
<br></td>
</tr>
<tr>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">Password</p></td>
<td><p style="font-family:times; color:black; font-size:20px; text-align:center">:</p></td>
<td><input type="password" name="Password" value="" size="20">
<br></td>
</tr>
</table>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</p>
<p style="font-family:times; color:black; font-size:20px; text-align:center">If you are a new customer, <a href="newcustomerlogin.htm">please follow this link...</a></p>
</body>
</html>
Post Reply