Jump to content

Recommended Posts

I have a form that asks for phonenumber.  The phone number is sticky, but it is just storing a '0' in my database.  Anyone know what is wrong?


<tr>	<td> <span class="star"> * </span> Phone #: </td> <td>
			<input type="text" name="phonenumber[]" value="<?php if(isset($_POST['signup'])) echo $_POST['phonenumber']['0']; ?>"  maxlength="3" size="3" /> 
			<input type="text" name="phonenumber[]" value="<?php if(isset($_POST['signup'])) echo $_POST['phonenumber']['1']; ?>" maxlength="3" size="3" /> 
			<input type="text" name="phonenumber[]" value="<?php if(isset($_POST['signup'])) echo $_POST['phonenumber']['2']; ?>" maxlength="4" size="4" /> </td> </tr>

Link to comment
https://forums.phpfreaks.com/topic/190866-another-problem-with-my-code/
Share on other sites

Here is all my code for the page.  If you could help, i would really appreciate it.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<html>
<head>

	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<title> TheTextNook Sign up - Results </title>
	<link type="text/css" rel="stylesheet" href="signup.css" />
</head>

<body>

	<div id="allcontent">

	<h1> <span id="title"> Title </span> <span id="home"> <a href="home.html"> Home </a> </span> </h1>

		<h2> XXXXXXX </h2>

		<?php


		$firstname = ($_POST['firstname']);

		$lastname = ($_POST['lastname']);		

		$username = ($_POST['username']); 

		$password1 = ($_POST['password1']);

		$password2 = ($_POST['password2']);

		$phonenumber = ($_POST['phonenumber']);

		$sex = ($_POST['sex']);

		$month = ($_POST['month']);

		$day = ($_POST['day']);

		$year = ($_POST['year']);

		$categories = ($_POST['categories']);

		$days = ($_POST['days']);

		$text = ($_POST['text']);

		$comments = ($_POST['comments']);

		$submit = ($_POST['signup']);		




		if (isset($submit)) {
		$output_form = false;

		if (isset($firstname) && !empty($firstname)
		&& isset($lastname) && !empty($lastname) 
		&& isset($username) && !empty($username)
		&& isset($password1) && !empty($password1)
		&& isset($password2) && !empty($password2)
		&& isset($phonenumber) && !empty($phonenumber)
		&& isset($month) && !empty($month)
		&& isset($day) && !empty($day)
		&& isset($year) && !empty($year)
		&& isset($categories) && !empty($categories)
		&& isset($days) && !empty($days)
		&& isset($text) && !empty($text)
		&& isset($sex) && !empty($sex)
		&& ($password1 == $password2)) {

		$dbc = mysql_connect ('server', 'xxxxx', 'xxxxxx', 'xxxxxx')
		      or die ('Error connecting to MySQL server.');

		mysql_select_db ('thetextnook', $dbc);

		$query = "SELECT * FROM textnook WHERE phonenumber = '{$_POST['phonenumber']}'";

		$data = mysql_query ($query);			
		if (mysql_num_rows($data) == 0) {


		$query1 = "INSERT INTO textnook ( first_name, last_name, user_name, password, phonenumber, sex, month, day, year, category, days, text, comments)
			 VALUES ( '$firstname', '$lastname', '$username', '$password1', '$phonenumber', '$sex', '$month','$day', '$year', '$categories', '$days', '$text','$comments')";

		$result = mysql_query ($query1, $dbc)
		      or die ("MYSQL ERROR: $query1 - " . mysql_error());


		echo 'Sign Up Confirmed' . '<br /> <br />';					

		echo 'Thanks for joining TextNook!' . '<br /> <br />'; 	

		echo 'You have signed up to receive :' .implode(", ",$_POST['categories']) . '<br /> <br />';

		echo 'You have signed up to receive '  .implode(", ",$_POST['days']) . '<br /> <br />';

		echo 'And you have signed up to receive the following amount:' . $_POST['text'] . '<br /> <br />';

		echo 'You can change these selections at anytime by logging into your account.' . '<br /> <br />';

		echo 'Coming Soon: You will be able to choose individual stores and restraunts instead of entire categories.</span>' . '<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />';

		mysql_close ($dbc);
		exit();
		} 

		else {

		echo '<p> An account already exists with this username.  Please select a different username. </p>';
		$output_form = true;			

		}
		}

		else {			

		echo  'Attention! Unfortunately you did not provide all of the required sign up information. <br /> <br /> To sign up, please fill out all of the required form fields and make sure you confirm your password correctly.  Thankyou';
		$output_form = true;

		}			
		}

		else {

		$output_form = true; }

		if ($output_form) {

		?>		

		<div id="form">

		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">		

		<table>

		<tr>			

		<th> General Info: </th> <td id="us"> Tell Us About Yourself </td> </tr> <tr> <th> </th> 

		<td>

		<table>
			<tr>		

			<td> <span class="star"> * </span> Firstname: </td> <td> <input type="text" name="firstname" value="<?php if(isset($_POST['signup'])) echo $_POST['firstname']; ?>" /> </td> </tr>	

		<tr>	<td> <span class="star"> * </span> Lastname: </td> <td> <input type="text" name="lastname" value="<?php if(isset($_POST['signup'])) echo $_POST['lastname']; ?>" /> </td> </tr> 

		<tr>	<td> <span class="star"> * </span> Username: </td> <td> <input type="text" name="username" value="<?php if(isset($_POST['signup'])) echo $_POST['username']; ?>" /> </td> </tr>

		<tr>	<td> <span class="star"> * </span> Password: </td> <td> <input type="password" id="password1" name="password1" /> </td> </tr>

		<tr>    <td> <span class="star"> * </span> Confirm Password: </td> <td> <input type="password" id="password2" name="password2" /> </td> </tr>

		<tr>	<td> <span class="star"> * </span> Phone #: </td> <td>
			<input type="text" name="phonenumber[]" value="<?php if(isset($_POST['signup'])) echo $_POST['phonenumber']['0']; ?>"  maxlength="3" size="3" /> 
			<input type="text" name="phonenumber[]" value="<?php if(isset($_POST['signup'])) echo $_POST['phonenumber']['1']; ?>" maxlength="3" size="3" /> 
			<input type="text" name="phonenumber[]" value="<?php if(isset($_POST['signup'])) echo $_POST['phonenumber']['2']; ?>" maxlength="4" size="4" /> </td> </tr>

		<tr>	<td> <span class="star"> * </span> Sex: </td> <td> <input type="radio" name="sex" value="male"<?php if(isset($_POST['signup']) && isset($_POST['sex']) && $_POST['sex']=='male') echo "checked='checked'"; ?> /> male 
			     <input type="radio" name="sex" value="female"<?php if(isset($_POST['signup']) && isset($_POST['sex']) && $_POST['sex']=='female') echo "checked='checked'"; ?> /> female </td> </tr>

		<tr>	<td> <span class="star"> * </span> Date of Birth: </td> <td> <select name="month"> 
		<?php
		$months = array('jan'=>'January', 'feb'=>'February', 'mar'=>'March', 'apr'=>'April', 'may'=>'May', 'june'=>'June',
				'july'=>'July', 'aug'=>'August', 'sep'=>'September', 'oct'=>'October', 'nov'=>'November', 'dec'=>'December');
		foreach($months as $k1=>$v1) {
		$echo_out0 = "<option value='".$k1."'";
		if(isset($_POST['signup'])) {
		if($k1==$_POST['month']) {
		$echo_out0 .= " selected='selected'";
		}
		}
		$echo_out0 .=">".$v1."</option>\n";
		echo $echo_out0;
		}
		?>
		</select>			



		<select name="day"><?php
		for ($i = 1; $i <= 31; $i++) {
		$echo_out0_1 = "<option value='".$i."'";
		if(isset($_POST['signup'])) {
		if($i==$_POST['day']) {
		$echo_out0_1 .= " selected='selected'";
		}
		}
		$echo_out0_1 .= ">".$i."</option>";
		echo $echo_out0_1;
		}
		?>
		</select>



			<select name="year"><?php
			for ($i = 2010; $i >= 1900; $i--) {
			$echo_out0_2 = "<option value='".$i."'";
			if(isset($_POST['signup'])) {
			if($i==$_POST['year']) {
			$echo_out0_2 .= " selected='selected'";
			}
			}
			$echo_out0_2 .= ">".$i."</option>";
			echo $echo_out0_2;
			}
			?>

			</select> </td> </tr> </table> </td> </tr>

		<tr>

		     <th> <span class="star"> * </span> Categories: </th> <td id="cat"> Choose the categories  </td> </tr> <tr> <th> </th>		

		     <td>			    

		     <?php
		     $required_checkboxes = array('all'=>'All Categories', 'fastfood'=>'Fast Food', 'restaurants'=>'Restaurants', 'bars/clubs'=>'Bars/Clubs', 'a'=>'A', 'b'=>'B', 'c'=>'C');					
		     $counter = 1;
		     foreach($required_checkboxes as $k1=>$v1) {
		     $echo_out = "<input type='checkbox' name='categories[]' value='".$k1."'";
		     if(isset($_POST['signup']) && isset($_POST['categories'])) {
		     foreach($_POST['categories'] as $k2=>$v2) {
		     if ($k1==$v2) {
		     $echo_out .=" checked='checked'";
		     break 1;
		     }
		     }
		     }
		     $echo_out .= " /> ".$v1;

		     echo $echo_out;
		     $counter++;
		     if($counter>4) echo "<br />";
		     }
		     ?>

		     </td>
		     </tr>

		<tr> 

		     <th> <span class="star"> * </span> Days: </th> <td id="run"> Choose the days you  </td> </tr> <tr> <th> </th>

		     <td>

		     <?php
		     $days = array('Everyday','Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
		     foreach($days as $k1=>$v1) {
		     $echo_out2 = "<input type='checkbox' name='days[]' value='".$v1."'";
		     if(isset($_POST['signup']) && isset($_POST['days'])) {
		     foreach($_POST['days'] as $k2=>$v2) {
		     if ($v1==$v2) {
		     $echo_out2 .= " checked='checked'";
		     break 1;
		     }
		     }
		     }
		     $echo_out2 .= " /> ".$v1." <br />";

		     echo $echo_out2;
		     }
		     ?>		

		     </td>			

		</tr>

		<tr>			

		     <th> <span class="star"> * </span> # of Texts: </th> <td id="walk"> Choose the  / category / day </td> </tr> <tr> <th> </th> <td id="walk1"> NOTE: You may not always receive the max # of text messages </td> </tr> <tr> <th> </th>

		     <td> <select name="text">
		     <?php
		     $text_options = array('unlimited'=>'Unlimited', '1'=>'1', '3'=>'3', '5'=>'5', '10'=>'10', '15'=>'15', '20'=>'20', '25'=>'25', '50'=>'50');
		     foreach($text_options as $k1=>$v1) {
		     $echo_out3 = "<option value='".$k1."'";
		     if(isset($_POST['signup'])) {
		     if($k1==$_POST['text']) {
		     $echo_out3 .= " selected='selected'";
		     }
		     }
		     $echo_out3 .= ">".$v1."</option>\n";
		     echo $echo_out3;
		     }
		     ?>

		     </select> </td>

		</tr>

		<tr>

		<th> Comments: </th> 

		     <td>			     

		     <textarea name="comments" rows="10" cols="50"><?php if(isset($_POST['signup'])) echo $_POST['comments']; ?> Comments/Suggestions </textarea>

		     </td>			

		</tr>

		</table> 		

		<p id="end"> <input type="submit" value="SignUp" name="signup" /> </p>

	</form> </div>

	<?php
	} 
	?>


	<p id="copyright"> Copyright 2010 © TheTextNook.com - All rights reserved  <span id="about"> <a href="about.html"> About </a> </span> <span id="privacy"> <a href="about.html"> Privacy </a> </span> <span id="contact"> <a href="about.html"> Contact Us </a> </span> <span id="advertise"> <a href="about.html"> Advertise </a> </span>   </p>	

	</div>	

</body>

</html>

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.