Jump to content

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

escape quotes or change to single quotes:

 

<select name='sex'>
<option value='male'>male</option>
<option value='female'>female</option></select>

 

or

 

<select name=\"sex\">
<option value=\"male\">male</option>
<option value=\"female\">female</option></select>

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

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.