Jump to content

Recommended Posts

Ok so for some reasons on my register and edit profile page when i hit submit it says that i have not filled in all the info i need.. Even after i fill all of them in..

 

but heres the code for the register form..

 

<?php require("top.php"); ?>
<div id='homeright'>
<?php


echo "<font size='6'>Sign up</font>";

echo "<hr width='75%' align='left'/>";
$form = "<form action='index.php' method='post'>
<table cellspacing='5px'>



<tr>
	<td>First Name:</td>
	<td class='register'><input type='text' name='firstname' class='textbox' size='35'></td>
</tr>

	<tr>
	<td>Last Name:</td>
	<td><input type='text' name='lastname' class='textbox' size='35'></td>
</tr>

	<tr>
	<td>Username:</td>
	<td><input type='text' name='username' class='textbox' size='35'></td>
</tr>

	<tr>
	<td>E-mail:</td>
	<td><input type='text' name='email' class='textbox' size='35'></td>
</tr>

	<tr>
	<td>Password:</td>
	<td><input type='password' name='password' class='textbox' size='35'></td>
</tr>

	<tr>
	<td>Confirm Password:</td>
	<td><input type='password' name='repassword' class='textbox' size='35'></td>
</tr>

	<tr>
	<td></td>
	<td><input type='submit' name='submitbtn' value='Register' class='button'></td>
</tr>
</table>

</form>";


if ($_POST['submitbtn']){


$firstname = fixtext($_POST['firstname']);
$lastname = fixtext($_POST['lastname']);
$username = fixtext($_POST['username']);
$email = fixtext($_POST['email']);
$password = fixtext($_POST['password']);
$repassword = fixtext($_POST['repassword']);
$website = fixtext($_POST['website']);
$youtube = fixtext($_POST['youtube']);
$bio = fixtext($_POST['bio']);

$name = $_FILES['avatar'] ['name'];
$type = $_FILES['avatar'] ['type'];
$size = $_FILES['avatar'] ['size'];
$tmpname = $_FILES['avatar']['tmpname'];
$ext = substr($name, strrpos($name, '.'));

if ($firstname && $lastname && $username && $email && $password && $repassword){
	if ($password == $repassword){
		if (strstr($email, "@") && strstr($email, ".") && strlen($email) >= 6){

			require("scripts/connect.php");
			/*$query = mysql_query("SELECT * FROM users WHERE username='$username' ");*/
			$query=mysql_query("SELECT * FROM users WHERE username='$username' ") or die(mysql_error());
			$numrows = mysql_num_rows($query);
			if ($numrows == 0){

				/*$query=mysql_query("SELECT * FROM users WHERE email='$email' ");*/
				$query=mysql_query("SELECT * FROM users WHERE email='$email' ") or die(mysql_error());
				$numrows=mysql_num_rows($query);
				if ($numrows == 0){

				$pass = md5(md5($password));
				$date = date("F d, Y");

				if($name){
					move_uploaded_file($tmpname, "avatars/$username.$ext");
					$avatar = "$username.$ext";
				}
				else
					$avatar = "/avatars/default_avatar.png";

				$code = substr (md5(rand(11111111111, 999999999999999)), 2,  25);


				mysql_query("INSERT INTO users (`first_name`,`last_name`,`username`,`email`,`password`,`avatar`,`bio`,`website`,`youtube`,`last_login`,`active`,`code`,`locked`,`date`) VALUES ( '$firstname', '$lastname', '$username', '$email', '$pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')");

				/*mysql_query("INSERT INTO users (Field, Type) VALUES ('', '$firstname', '$lastname', '$username', '$email', 'pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')");*/

						$webmaster = "Admin@trucksite.com";
						$subject = "Activate Your Account!";
						$headers = "From: Admin <$webmaster>";
						$message = "Hello $firstname.\n\nWelcome to trucksite below is a link for you to activate your account!.\n http://tprofiletesting.net23.net/activate.php?code=$code";

						mail($email, $subject, $message, $headers);
						echo "Your activation email has been sent to <b>$email</b>.";
				}
				else
					echo "That email is currently in use.";

			}
			else
				echo "That username is currently in use.";
		}
		else
			echo "You did not enter a vaild email.";
	}
	else
		echo "Your passwords did not match.";
}
else
	echo"You did not fill in all the required fields.";
}
echo "$form";


?>

</div>
<div id='homeleft'>
<center><font size='6'>Create!	 Showoff! 	Educate!</font></center>
<hr />

</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/
Share on other sites

When validating user supplied information, you should supply as much information as possible as to why the information did not validate.

 

You should individually test each value and output a specific message for each validation problem found.

The recommend way of validating all the form fields individually is to use an array to hold the error message(s). You run all the possible validation tests and then at the end you simply test if there were any errors or not. See the following post for some example code - http://www.phpfreaks.com/forums/index.php?topic=340943.msg1607829#msg1607829

but why would i do this? like i know im filling in all the boxes and i know that only certin ones are required but idk why its not picking up on the info i put in .. on either form.

 

could it be becasue i copied and pasted the form from one page to antother?

 

but why would i do this?

 

So that your code would tell you which field(s) are failing, as that would point to where to look to find the cause of the problem. Right now, you don't even know if it is just one field or all of the fields that are not working.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.