Jump to content

Form partially submits


WilliamNova
Go to solution Solved by WilliamNova,

Recommended Posts

Wasn't sure how to word the subject.

Anyways, I have a form that is supposed to update multiple fields at once. Howevever, it's only updating the first one and that's gender. It will not update Location, or About or anything else.

 

Here's the function that's in an include file.

<?php
if (isset($_POST['gender']))
if (isset($_POST['location']))
if (isset($_POST['about']))
if (isset($_POST['twitter']))
if (isset($_POST['facebook']))
{
$gender = mysql_real_escape_string($_POST['gender']);
$location = mysql_real_escape_string($_POST['location']);
$about = mysql_real_escape_string($_POST['about']);
$twitter = mysql_real_escape_string($_POST['twitter']);
$facebook = mysql_real_escape_string($_POST['facebook']);


// Update
mysql_query("UPDATE users SET gender='$gender', location='$location', about='$about', twitter='$twitter', facebook='$facebook' WHERE user_id='$user_id'");
}
 ?>

Here's the form

			<form action='home.php' method='POST'>
				<b>Gender:</b> <?php echo "$gender"; ?><br />
				<input type='radio' name='gender' value='Male' />Male
				<input type='radio' name='gender' value='Female' />Female<br />
			<br />
				<b>Location:</b><br />
				<textarea name='location' value='location' class='ta3'><?php echo "$location"; ?></textarea><br />
			<br />
				<b>About:</b> (150 chars or less)<br />
				<textarea name='about' value='about'><?php echo '$about'; ?></textarea><br />
			<br />
				<b>My Twitter:</b><br />
				@<textarea name='twitter' value='twitter' class='ta4'><?php echo "$twitter"; ?></textarea><br />
				<br />
				<b>My Facebook:</b><br />
				facebook.com/<textarea name='facebook' value='facebook' class='ta4'><?php echo "$facebook"; ?></textarea><br />
				<input type='submit' name='submit' value='Update' />
			</form>
Link to comment
Share on other sites

For what it's worth, the original form (with the radio buttons) works fine for me. Well, except for the $about variable being enclosed in single quotes.

<textarea name='about' value='about'><?php echo '$about'; ?></textarea><br />

You either need to use double quotes or they could be left off altogether.

<textarea name='about' value='about'><?php echo $about; ?></textarea><br />

Perhaps there was a MySQL error, did you try using mysql_error()? More information and examples can be found here:

http://www.php.net/mysql_error

 

Did you try seeing what the variables contained? For example, the following would have told you if your location variables actually contained any data:

$location = mysql_real_escape_string($_POST['location']);
var_dump($_POST['location']);
var_dump($location);
Link to comment
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.