Jump to content

error


ecabrera

Recommended Posts

maybe it should be:

$sex = fixtext($_POST["sex"]);

 

although that's very little info and code for us to figure it out.

 

try something like this:

 

if(isset($_POST['sex'])){
echo 'variable exists.';
}else{
echo 'Variable did not reach this page';
}

 

p.s. I'm not even going to ask what the content of that variable is, or did you mean 'gender' ...

Link to comment
https://forums.phpfreaks.com/topic/244652-error/#findComment-1256632
Share on other sites

yes i mean gender but i prefer sex i dont why

 

		
	if (@$_POST['savebtn']){
		$firstname = fixtext($_POST['firstname']);
		$lastname = fixtext($_POST['lastname']);
		$email = fixtext($_POST['email']);
		$youtube = fixtext($_POST['youtube']);
		$bio = fixtext($_POST['bio']);
                        $sex = $_POST["sex"];
		$password = fixtext($_POST['password']);

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

		if ($firstname && $lastname && $email && $password){
			if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)){
				$password = md5(md5($password));
				$query = mysql_query("SELECT * FROM users WHERE id='$userid' AND password='$password'");
				$numrows = mysql_num_rows($query);
				if ($numrows == 1){
					// set firstname
					mysql_query("UPDATE users SET first_name='$firstname' WHERE id='$userid'");
					// set lastname
					mysql_query("UPDATE users SET last_name='$lastname' WHERE id='$userid'");
					// set email
					mysql_query("UPDATE users SET email='$email' WHERE id='$userid'");
					// set youtube
					mysql_query("UPDATE users SET youtube='$youtube' WHERE id='$userid'");
                                                // set sex
					mysql_query("UPDATE users SET sex='$sex' WHERE id='$userid'");
					// set bio
					mysql_query("UPDATE users SET bio='$bio' WHERE id='$userid'");

					if ($name){
						$avatarname = "$username"."$ext";
						move_uploaded_file($tmpname, "avatars/$avatarname");
						// set bio
						mysql_query("UPDATE users SET avatar='$avatarname' WHERE id='$userid'");
					}

					echo "Your information has been saved.";
				}
				else
					echo "Your password was incorrect.";
			}
			else
				echo "You did not provide a valid email.";
		}
		else
			echo "You did not provied the required info.";
	}



	$query = mysql_query("SELECT * FROM users WHERE id='$userid'");
	$numrows = mysql_num_rows($query);
	if ($numrows == 1){
		$row = mysql_fetch_assoc($query);
		$id = $row['id'];
		$firstname = $row['first_name'];
		$lastname = $row['last_name'];
		$email = $row['email'];
		$avatar = $row['avatar'];
		$bio = $row['bio'];
                        $sex = $row['sex'];
		$youtube = $row['youtube'];
		$lastlogin = $row['last_login'];
		$active = $row['active'];
		$locked = $row['locked'];
		$date = $row['date'];
	}
	else
		echo "An error occured while connecting to the database.";

	$infoform = "<form action='edit_profile.php' method='post' enctype='multipart/form-data'>
	<table cellspacing='10px'>
	<tr>
		<td></td>
		<td><font color='red'>*</font> are required</td>
	</tr>
	<tr>
		<td>First Name:</td>
		<td><input type='text' name='firstname' class='textbox' size='35' value='$firstname'><font color='red'>*</font></td>
	</tr>
	<tr>
		<td>Last Name:</td>
		<td><input type='text' name='lastname' class='textbox' size='35' value='$lastname'><font color='red'>*</font></td>
	</tr>
	<tr>
		<td>Email:</td>
		<td><input type='text' name='email' class='textbox' size='35' value='$email'><font color='red'>*</font></td>
	</tr>
	<tr>
		<td>Avatar:</td>
		<td><input type='file' name='avatar'></td>
	</tr>
	<tr>
	<tr>
		<td>Youtube Username:</td>
		<td><input type='text' name='youtube' class='textbox' size='35' value='$youtube'></td>
	</tr>
	<tr>
		<td>Bio/About:</td>
		<td><textarea name='bio' cols='35' rows='5' class='textbox'>$bio</textarea></td>
	</tr>
                <tr>
	<td>Gender:</td>
	<td><select> 
                <option>Female</option>
                <option>Male</option>
                </select>
                </td>
	<tr>
		<td>Current Password:</td>
		<td><input type='password' name='password' class='textbox' size='35'></td>
	</tr>
	<tr>
		<td></td>
		<td><input type='submit' name='savebtn' value='Save Changes' class='button'></td>
	</tr>
	</table>
	</form>";

	echo "$infoform";

Link to comment
https://forums.phpfreaks.com/topic/244652-error/#findComment-1256635
Share on other sites

Gender:</td>
	<td><select> 
                <option>Female</option>
                <option>Male</option>
                </select>

is missing the select name and values. Should be

Gender:</td>
	<td><select name="sex"> 
                <option value="Female">Female</option>
                <option value="Male">Male</option>
                </select>

Link to comment
https://forums.phpfreaks.com/topic/244652-error/#findComment-1256638
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.