Page 1 of 2

Anything wrong?

Posted: Sun Jun 12, 2005 3:04 pm
by Parody

Code: Select all

<?php
if(preg_match("/(\<|\>)/", $_POST['uname']) | preg_match("/(\<|\>)/")) {
		die('Invalid input, no tags /(/< or />/) are allowed in your username.');
		$test = strstr($email, '@');
if($test != false) 
{}
else{die('The email address you entered does not contain the /@ symbol.');
$rand = rand(10248765,99543547);
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("users") or die('Sorry, we are having database connection problems, please report this to an Administrator');
$regdate = date('m d, Y');
$qry = "INSERT INTO users (username, password, regdate, email) VALUES ('".$_POST['uname']."', '".$rand."', '".$regdate."', '".$_POST['email']."')";
mysql_query($qry)  or die(mysql_error());
mysql_query("INSERT INTO stats('".$_POST['uname']."','$chrctr', '100', '2000', '001', '01', 000, '01', '01', '01', '1', '0', '00000000', '00000000', '00000000', '00000000')");
mysql_close();
print "You successfully registered as('".$_POST['uname']."')";
?>
Any ideas?

I just get a parse error on the bottom line

Re: Anything wrong?

Posted: Sun Jun 12, 2005 3:09 pm
by wwwapu
Parody wrote:

Code: Select all

print "You successfully registered as('".$_POST['uname']."')";
try

Code: Select all

print 'You successfully registered as(\''.$_POST['uname'].'\')'; //escape
//or
print 'You successfully registered as(´'.$_POST['uname'].'´)';
//or
print 'You successfully registered as("'.$_POST['uname'].'")';
It seems like problems with quotemarks ' is "stronger" than ".

Posted: Sun Jun 12, 2005 3:11 pm
by Parody
I still get the error,

Parse error on line 17

Posted: Sun Jun 12, 2005 3:13 pm
by cbrian
i think your missing an ending } for the else {

Posted: Sun Jun 12, 2005 5:00 pm
by Skara
All of the following are perfectly valid:

Code: Select all

print "You successfully registered as('".$_POST['uname']."')";

Code: Select all

print 'You successfully registered as("'.$_POST['uname'].'")';

Code: Select all

print 'You successfully registered as(\''.$_POST['uname'].'\')';

Code: Select all

print "You successfully registered as(\"".$_POST['uname']."\")";

Code: Select all

print "You successfully registered as('{$_POST['uname']}')";
' and " are interchangeable except " parses where ' doesn't.

Posted: Sun Jun 12, 2005 5:59 pm
by John Cartwright
I generally would never use die() unless it was a fatal error, so I frown on your use of it. However, this is what you want.

Code: Select all

if(preg_match("/(\<|\>)/", $_POST['uname'])) {
		die('Invalid input, no tags /(/< or />/) are allowed in your username.');
	}
	if (preg_match("^[a-z0-9\._-]+@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+)^",$_POST['email'])) {
		die('Email Adress invalid.');
	}

	$rand = rand(10248765,99543547);
	mysql_connect("localhost", "username", "password") or die(mysql_error());
	mysql_select_db("users") or die('Sorry, we are having database connection problems, please report this to an Administrator');
	$regdate = date('m d, Y');
	$qry = "INSERT INTO users (username, password, regdate, email) VALUES ('".$_POST['uname']."', '".$rand."', '".$regdate."', '".$_POST['email']."')";
	mysql_query($qry)  or die(mysql_error());
	mysql_query("INSERT INTO stats('".$_POST['uname']."','$chrctr', '100', '2000', '001', '01', 000, '01', '01', '01', '1', '0', '00000000', '00000000', '00000000', '00000000')");
	mysql_close();
	print "You successfully registered as('".$_POST['uname']."')";

Posted: Mon Jun 13, 2005 11:11 am
by Parody
This is the page before, the form. For some reason when I click the submit button it wont proceed onto the next page :(

It just does nothing.

This is the code:

Code: Select all

<html>
<head>
<title>Register an Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css"
href="style.css" />
</head>
<body>
<h1 align="center">Please enter your preferable username and enter your email address.</h1>
 <form name="input" form action="registering2.php" method="post">
   <table border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#FFFFFF">
     <tr>
       <td class="h1"><span class="style3">
         <h1>Username:</h1>
       </span></td>
       <td class="style5"><input type="text" name="uname" maxlength="20"></td>
     </tr>
     <tr>
       <td class="h1"><span class="style3">
         <h1>Email:</h1>
       </span></td>
       <td class="style5"><input type="text" name="email" maxlength="100"></td>
     </tr>
	 <tr>
       <td class="h1"><span class="style3">
         <h1>Character</h1>
       </span></td>
       <td class="style5"><input name="chrctr" type="text" id="chrctr" value="1" maxlength="2"></td>
     </tr>
  <tr bordercolor="#FFFFFF">
   </table> 
</form>
<h1 align="center">Choose a Display Picture and type its number into the space provided above </h1>
<div align="center">
  <table width="600" border="1">
    <tr>
      <td width="100"><img src="/characters/1.jpg" width="100" height="150"></td>
      <td width="100"><img src="/characters/2.jpg" width="100" height="150"></td>
      <td width="100"><img src="/characters/3.jpg" width="100" height="150"></td>
      <td width="100"><img src="/characters/4.jpg" width="100" height="150"></td>
      <td width="100"><img src="/characters/5.jpg" width="100" height="150"></td>
      <td width="108"><div align="center"><img src="/characters/6.jpg" width="100" height="150"></div></td>
    </tr>
    <tr>
      <td><h1 align="center">1</h1></td>
      <td><h1 align="center">2</h1>
      </td>
      <td><h1 align="center">3</h1>
        </td>
           <td><h1 align="center">4</h1>
        </td>
      <td><h1 align="center">5</h1>
        </td>
      <td><h1 align="center">6</h1>
      </td>
    </tr>
  </table>
  <p>&nbsp;</p>
<table width="600" border="1">
  <tr>
    <td width="100"><img src="/characters/7.jpg" width="100" height="150"></td>
    <td width="100"><img src="/characters/8.jpg" width="100" height="150"></td>
    <td width="100"><img src="/characters/9.jpg" width="100" height="150"></td>
    <td width="100"><img src="/characters/10.jpg" width="100" height="150"></td>
    <td width="100"><img src="/characters/11.jpg" width="100" height="150"></td>
    <td width="108"><img src="/characters/12.jpg" width="100" height="150"></td>
    <td width="108"><img src="/characters/13.jpg" width="100" height="150"></td>
  </tr>
  <tr>
    <td><h1 align="center">7 </h1>
     </td>
    <td><h1 align="center">8</h1>
      </td>
    <td><h1 align="center">9</h1>
      </td>
    <td><h1 align="center">10</h1>
      </td>
    <td><h1 align="center">11</h1>
      </td>
    <td><h1 align="center">12</h1>
      </td>
    <td><h1 align="center">13</h1>
      </td>
  </tr>
</table>
<p>&nbsp;</p>
</div>
<div align="center">
<div align="center">
  <input name="submit" type="submit" value="Sign Up">
</div><br>
</html>
Can anyone suggest any reason for this please :?:

Posted: Mon Jun 13, 2005 11:24 am
by John Cartwright
Put your submit button inside the form.

Posted: Mon Jun 13, 2005 12:37 pm
by Parody
Jcart: I am having a slight problem with my email verification :(

Whenever I put in my own email address it displays email address not valid

Any ideas please :?:

Posted: Mon Jun 13, 2005 1:41 pm
by shiznatix
then your regular expression is not valid id bet

Posted: Mon Jun 13, 2005 3:00 pm
by Parody
:?: :?: :?: :?: :?: :?: What :?: :?: :?: :?: :?: :?:

Posted: Mon Jun 13, 2005 5:17 pm
by shiznatix
err sorry you are not using a regular expression to match the email :oops: , don't strstr to do it, use strpos

Posted: Tue Jun 14, 2005 10:16 am
by Parody
I now have a parse error on line 6, but it is just:

Code: Select all

else{
This is the code at the moment:

Code: Select all

<?php
if(preg_match("/(\<|\>)/", $_POST['uname'])) {
        die('Invalid input, no tags < or > are allowed in your username.');
} 
if (preg_match("^[a-z0-9\._-]+@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+)^",$_POST['email']))
else{
die{'Email Adress invalid, you entered: '.$_POST['email'].''};
}
$rand = rand(10248765,99543547);    
mysql_connect("localhost", "admin", "ak7456") or die(mysql_error());
mysql_select_db("users") or die('Sorry, we are having database connection problems, please report this to an Administrator');    
$regdate = date('m d, Y');
$chrctr =  $_POST['email'];   
$qry = "INSERT INTO users (username, password, regdate, email) VALUES ('".$_POST['uname']."', '".$rand."', '".$regdate."', '".$_POST['email']."')";    
mysql_query($qry)  or die(mysql_error());    
mysql_query("INSERT INTO stats('".$_POST['uname']."','$chrctr', '100', '2000', '001', '01', 000, '01', '01', '01', '1', '0', '00000000', '00000000', '00000000', '00000000')");    
mysql_close();    
print "You successfully registered as'".$_POST['uname']."'";
   ?>

Posted: Tue Jun 14, 2005 11:10 am
by phpScott
your if statment above doesn't do anything if it is true. so your missing {} before your else statment.

Posted: Tue Jun 14, 2005 11:29 am
by Parody
I tried that just then, nothing different, can you write out the code you suggest, I may have misunderstood :oops: