Page 1 of 1

Register Form Problems

Posted: Wed Dec 15, 2004 6:28 pm
by mmc01ms

Code: Select all

<?php
	
	require_once('useful_stock_fns.php');
	
	function in_use($username){
		
		
		$username = $_POST['username'];
		
		
		$link_id = db_connect() or die ("Couldn't connect to server.");
		
		$query = "SELECT username FROM customers WHERE username = '$username' ";
		$result = mysql_query($query, $link_id);
		if(!mysql_num_rows($result)) return 0;
		else return 1;
	}	
	
	function register_form(){
		
?>
<td>			
			<form name="register" method="post" action="register.php?action=register">
				<table>
					<tr>
						<td>* Enter Desired Username: </td>
						<td><input name="username" type="text" maxlength="10" id="username"></td>
					</tr>
					<tr>
						<td>* Enter Desired Password: </td>
						<td><input name="password" type="password" maxlength="10" id="password"></td>
					</tr>
					<tr>
						<td>* Type Password Again: </td>
						<td><input name="password2" type="password" maxlength="10" id="password2"></td>
					</tr>
					<tr>
						<td>* Email: </td>
						<td><input name="email" type="text" maxlength="40" id="email"></td>
					</tr>
					<tr>
						<td>* First Name: </td>
						<td><input name="firstName" type="text" maxlength="20" id="firstName"></td>
					</tr>
					<tr>
						<td>* Last Name: </td>
						<td><input name="lastName" type="text" maxlength="20" id="lastName"></td>
					</tr>
					<tr>
						<td>* Inital: </td>
						<td><input name="inital" type="text" maxlength="4" id="inital"></td>
					</tr>
					<tr>
						<td>* Address Line One: </td>
						<td><input name="addressLineOne" type="text" maxlength="25" id="addressLineOne"></td>
					</tr>
					<tr>
						<td>* Address Line Two: </td>
						<td><input name="addressLineTwo" type="text" maxlength="25" id="addressLineTwo"></td>
					</tr>
					<tr>
						<td>* City:  </td>
						<td><input name="city" type="text" maxlength="15" id="city"></td>
					</tr>
					<tr>
						<td>County:  </td>
						<td><input name="county" type="text" maxlength="15" id="county"></td>
					</tr>
					<tr>
						<td>* Postcode:  </td>
						<td><input name="postcode" type="text" maxlength="8" id="postcode"></td>
					</tr>
					<tr>
						<td>* Home Phone Number:  </td>
						<td><input name="homePhoneNumber" type="text" maxlength="11" id="homePhoneNumber"></td>
					</tr>
					<tr>
						<td>* Mobile Number:  </td>
						<td><input name="mobilePhoneNumber" type="text" maxlength="11" id="mobilePhoneNumber"></td>
					</tr>
					<tr>
						<td>* Date of Birth:  </td>
						<td>Day: <select name ="day">
								<option>1</option>
								<option>2</option>
								<option>3</option>
								<option>4</option>
								<option>5</option>
								<option>6</option>
								<option>7</option>
								<option>8</option>
								<option>9</option>
								<option>10</option>
								<option>11</option>
								<option>12</option>
								<option>13</option>
								<option>14</option>
								<option>15</option>
								<option>16</option>
								<option>17</option>
								<option>18</option>
								<option>19</option>
								<option>20</option>
								<option>21</option>
								<option>22</option>
								<option>23</option>
								<option>24</option>
								<option>25</option>
								<option>26</option>
								<option>27</option>
								<option>28</option>
								<option>29</option>
								<option>30</option>
								<option>31</option>
							</select>
							Month: <select name ="month">
								<option>1</option>
								<option>2</option>
								<option>3</option>
								<option>4</option>
								<option>5</option>
								<option>6</option>
								<option>7</option>
								<option>8</option>
								<option>9</option>
								<option>10</option>
								<option>11</option>
								<option>12</option>
							</select>
							Year: <select name ="year">
								<option>1950</option>
								<option>1951</option>
								<option>1952</option>
								<option>1953</option>
								<option>1954</option>
								<option>1955</option>
								<option>1956</option>
								<option>1957</option>
								<option>1958</option>
								<option>1959</option>
								<option>1960</option>
								<option>1961</option>
								<option>1962</option>
								<option>1963</option>
								<option>1964</option>
								<option>1965</option>
								<option>1966</option>
								<option>1967</option>
								<option>1968</option>
								<option>1969</option>
								<option>1970</option>
								<option>1971</option>
								<option>1972</option>
								<option>1973</option>
								<option>1974</option>
								<option>1975</option>
								<option>1976</option>
								<option>1977</option>
								<option>1978</option>
								<option>1979</option>
								<option>1980</option>
								<option>1981</option>
								<option>1982</option>
								<option>1983</option>
								<option>1984</option>
								<option>1985</option>
								<option>1986</option>
								<option>1987</option>
								<option>1988</option>
							</select>
						</tr>
						<tr>
						</td>
						<td>
							<input type="submit" name="Submit" value="Submit">
							<input type="reset" name="Reset" value="Reset">
						</td>
					</tr>
				</table>
				
				
			</form>
		</center>
</table>
	</body>
</html>

<?php
	}
	
	function create_account() {
		
		$username = $_POST['username'];
		$firstname = $_POST['firstName'];
		$surname = $_POST['lastName'];
		$inital = $_POST['inital'];
		$address_line_one = $_POST['addressLineOne'];
		$address_line_two =$_POST['addressLineTwo'];
		$city = $_POST['city'] ;
		$county = $_POST['county'] ;
		$postcode = $_POST['postcode'];
		$home_phone_number = $_POST['homePhoneNumber'] ;
		$mobile_number = $_POST['mobilePhoneNumber'] ;
		$email = $_POST['email'] ;
		$password = $_POST['password'] ;
		$password2 = $_POST['password2'] ;
		$date_of_birth = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
		
		//if((isset($_POST['password'])) != (isset($_POST['password2']))) error_message("Passwords do not match please re-enter them.");
		if(empty($username)) error_message("Enter your desired Username.");
		if(empty($password)) error_message("Please enter a password.");
		if(empty($firstname)) error_message("Please enter a firstname.");
		if(empty($surname)) error_message("Please enter a last name.");
		if(empty($email)) error_message("Please a enter an email.");
		if(strlen($password < 4 )) error_message("Password too short must be more then 4 characters.");
		if(empty($password2)) error_message("Please re-enter second password for verification.");
		if(empty($email)) error_message("Enter your email.");
		if(empty($address_line_one)) error_message("Enter your address.");
		if(empty($address_line_two)) error_message("Enter the second line of your address.");
		if(empty($postcode)) error_message("Please enter your postcode.");
		if(empty($city)) error_message("Enter the city you live in.");
		if(empty($home_phone_number)) error_message("Please enter a home phone number.");
		if(empty($mobile_number)) error_message("Please enter a mobile phone number.");
		if(empty($inital)) error_message("Please enter your title.");
		if(strlen($home_phone_number  < 11)) error_message("Invalid Home Phone Number.");
		if(strlen($mobile_number < 11)) error_message("Invalid Mobile Phone Number.");
		if(empty($date_of_birth)) error_message("Invalid Birth Date");
		
		
		if(in_use($username))
			error_message("$username is in use. Please choose a diffrent ID.");
		
		
		
		$link_id = db_connect()	or die (mysql_error());
		
		
		
		if(!$county){
			
			$query = "insert into customers (NULL, 'first_name', 'surname', 'inital', 'address_line_one', 'address_line_two', 'city','postcode', 'home_phone_number', 'mobile_number', 'email', 'date_of_birth', 'username', 'password', NULL, NULL)
									 values (NULL, '$firstname','$surname,'$inital', '$address_line_one', '$address_line_two', '$city','$postcode', '$home_phone_number', '$mobile_number', '$email', '$date_of_birth', '$username', '$password1', NULL, NULL)";
				$result = mysql_query($query, $link_id) or die(mysql_error());		
			if($result)
			{
				send_validation_email();
			}
			
		}
		
		if ($firstName && $lastName && $inital && $addressLineOne && $addressLineTwo && $city && $county && $postcode && $homePhoneNumber && $mobilePhoneNumber && $email && $Date_of_Birth && $password1 && $password2){
			
			$query = "insert into customers (NULL, 'first_name', 'surname', 'inital', 'address_line_one', 'address_line_two', 'city', 'county','postcode', 'home_phone_number', 'mobile_number', 'email', 'date_of_birth', 'username', 'password', NULL, NULL)
									 values (NULL, '$firstname','$surname,'$inital', '$address_line_one', '$address_line_two', '$city', '$county', '$postcode', '$home_phone_number', '$mobile_number', '$email', '$date_of_birth', '$username', '$password1', NULL, NULL)";
				$result = mysql_query($query, $link_id) or die(mysql_error());		
			if($result)
			{
				send_validation_email();
			}
			
		}
		
		function send_validation_email()
		{
			echo $firstName
				." "
				. $lastName 
				. ", You have succesfully become a customer of Funky Monkey Records. You will recieve a validation e-mail so you can activiate your account.<br><br>
						";
				$link_id = db_connect();
			$query= mysql_query("Select customer_id from customers where username = '$username'");
			$row = mysql_fetch_array($query);
			$customer_id = $row['customer_id'];
			
			$emailMessage = "<html><body>Dear ". $firstName . " " . $lastName. "<br><br>
				You have registred an account at Funky Monkey Records. In order to complete registration you have to click this activation
				link:<br><a href="validate.php?page=validate&customer_id=" . $customer_id . "">validate.php?page=validation&customer_id=" . $customer_id . "</a></body></html>";
			
			$to = $email;
			$from = "mmc01ms@hotmail.com";
			$message= $emailMessage;
			$subject = "Succesfully registred as ". $username;
			$headers = "From: $from";
			if(mail($to,$subject,$message,$headers)){
			} else{
				echo"<br><br>Failed sending an email";
				
			}
		}
	}
?>

this code doesn't seem to be able to pick up the password field when the form is submitted. I keep getting the form returning saying i haven't entred a password field when i have?any one spot the mistake?

Posted: Wed Dec 15, 2004 6:40 pm
by rehfeld
make sure the names in the html form matche the $_POST['password'] and $_POST['password2']

i bet your form is
<input name="password1"

but your trying to receive
$_POST['password']


in situations like this, it can be helpfull to see what php is actually receiving by doing
print_r($_POST);

Posted: Wed Dec 15, 2004 7:10 pm
by ol4pr0
I dotn think it got something to do with ure form. cuase that returns everything in the right way.

Code: Select all

Array ( &#1111;username] =&gt; t &#1111;password] =&gt; t &#1111;password2] =&gt; t &#1111;email] =&gt; t &#1111;firstName] =&gt; t &#1111;lastName] =&gt; t &#1111;inital] =&gt; t &#1111;addressLineOne] =&gt; t &#1111;addressLineTwo] =&gt; t &#1111;city] =&gt; t &#1111;county] =&gt; t &#1111;postcode] =&gt; t &#1111;homePhoneNumber] =&gt; t &#1111;mobilePhoneNumber] =&gt; t &#1111;day] =&gt; 1 &#1111;month] =&gt; 1 &#1111;year] =&gt; 1950 &#1111;Submit] =&gt; Submit )
But i dont see whats next after you hit the submit button. ( where does it go ? ) i see function create_account but not the execution of that function ( i might be missing something here )

Code: Select all

if (!empty($_POST['password']) && !empty($_POST['password2']) && $_POST['password'] == $_POST['password2'])  
{ do something } 
else 
{ something else } 
# if password and password2 are not empty and they do match  its a go
try a print_r ( $_POST ); inside that create_account function

Posted: Thu Dec 16, 2004 5:44 pm
by mmc01ms
cheers guys these helped however i'v tweeked a few things and this hasn't helped. After i enter all fields and press submits the send_validation_email(); isn't intiated. In fact it just displays the form again to re-enter data. I've tried doing an echo statement instead of the function but still nothing is returned just the form any tips? code for the register.php page and functiosn are below. By the way i did the p_r($_post) statement and it produced:

Code: Select all

Array ( &#1111;username] =&gt; blue &#1111;password] =&gt; wing &#1111;password2] =&gt; wing &#1111;email] =&gt; mmc01ms@hotmail.com &#1111;firstName] =&gt; manpreet &#1111;lastName] =&gt; Smith &#1111;inital] =&gt; mr &#1111;addressLineOne] =&gt; 64 christina cresecent &#1111;addressLineTwo] =&gt; cinderhill &#1111;city] =&gt; nottingham &#1111;county] =&gt; nottinghamshire &#1111;postcode] =&gt; ng6 8sh &#1111;homePhoneNumber] =&gt; 01159704383 &#1111;mobilePhoneNumber] =&gt; 07797987689 &#1111;day] =&gt; 1 &#1111;month] =&gt; 1 &#1111;year] =&gt; 1950 &#1111;Submit] =&gt; Submit )
if thats any help.

Code: Select all

<?php 

	require('page.inc');
	
	
	require('register_functions.php');
	
	
	$registerpage = new Page();
	
	$registerpage -> setContent('<center><table width="779" border="0" cellspacing="2" cellpadding="2" >
 
  <tr> 
    <td width="30%" height="0"></td>
    <td width="70%"></td>
  </tr>
  <tr>
    <td height="156" valign="top"><center><table width="162" border="1" cellspacing="2" cellpadding="2" bgcolor="#7b9815" bordercolor="#d2e982">
        
        <tr> 
          <td width="200" align="center" valign="middle" bgcolor="#44802c"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">Welcome DJ''s </div></font></td>
        </tr>
        <tr> 
          <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">p: 0115 9706854</div></font></td>
        </tr>
        <tr> 
          <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">e: enqiures@funkymonkey.co.uk</div></font></td>
        </tr>
        <tr> 
         <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">f: 0115 9706855</div></font></td>
        </tr>
        <tr> 
          <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">18 Main Street, Hockley, Nottingham, NG1 7DD</div></font></td>
        </tr>
        
		<tr> 
          <td width="200" align="center" valign="middle" bgcolor="#44802c"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">Menu</div></font></td>
        </tr>
        <tr> 
          <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="logout.php">Logout</a></div></font></td>
        </tr>
        <tr> 
          <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="register2.php">Sign-up for an Account</a></div></font></td>
        </tr>
        <tr> 
         <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="newreleases.php">Just In</a></div></font></td>
        </tr>
        <tr> 
          <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="barginbins.php">Bargin Bins</a></div></font></td>
        </tr>
        </tr>
      </table></center></td>');
		
		$registerpage -> Display();
	
		register_form();

	
	
	if($_GET['action'] == "register")
	{
		create_account();
		exit;
		break;
	}
	else
		
		
		
		
?>
the functiosn for this page are.

Code: Select all

<?php
	
	require_once('useful_stock_fns.php');
	
	function in_use($username){
		
		
		$username = $_POST['username'];
		
		
		$link_id = db_connect() or die ("Couldn't connect to server.");
		
		$query = "SELECT username FROM customers WHERE username = '$username' ";
		$result = mysql_query($query, $link_id);
		if(!mysql_num_rows($result)) return 0;
		else return 1;
	}	
	
	function register_form(){
		
?>
<td>			
	<form name="register" method="post" action="register.php?action=register">
		<table>
			<tr>
				<td>* Enter Desired Username: </td>
				<td><input name="username" type="text" maxlength="10" id="username"></td>
			</tr>
			<tr>
				<td>* Enter Desired Password: </td>
				<td><input name="password" type="password" maxlength="10" id="password"></td>
			</tr>
			<tr>
				<td>* Type Password Again: </td>
				<td><input name="password2" type="password" maxlength="10" id="password2"></td>
			</tr>
			<tr>
				<td>* Email: </td>
				<td><input name="email" type="text" maxlength="40" id="email"></td>
			</tr>
			<tr>
				<td>* First Name: </td>
				<td><input name="firstName" type="text" maxlength="20" id="firstName"></td>
			</tr>
			<tr>
				<td>* Last Name: </td>
				<td><input name="lastName" type="text" maxlength="20" id="lastName"></td>
			</tr>
			<tr>
				<td>* Inital: </td>
				<td><input name="initial" type="text" maxlength="4" id="initial"></td>
			</tr>
			<tr>
				<td>* Address Line One: </td>
				<td><input name="addressLineOne" type="text" maxlength="25" id="addressLineOne"></td>
			</tr>
			<tr>
				<td>* Address Line Two: </td>
				<td><input name="addressLineTwo" type="text" maxlength="25" id="addressLineTwo"></td>
			</tr>
			<tr>
				<td>* City:  </td>
				<td><input name="city" type="text" maxlength="15" id="city"></td>
			</tr>
			<tr>
				<td>County:  </td>
				<td><input name="county" type="text" maxlength="15" id="county"></td>
			</tr>
			<tr>
				<td>* Postcode:  </td>
				<td><input name="postcode" type="text" maxlength="8" id="postcode"></td>
			</tr>
			<tr>
				<td>* Home Phone Number:  </td>
				<td><input name="homePhoneNumber" type="text" maxlength="11" id="homePhoneNumber"></td>
			</tr>
			<tr>
				<td>* Mobile Number:  </td>
				<td><input name="mobilePhoneNumber" type="text" maxlength="11" id="mobilePhoneNumber"></td>
			</tr>
			<tr>
				<td>* Date of Birth:  </td>
				<td>Day: <select name ="day">
						<option>1</option>
						<option>2</option>
						<option>3</option>
						<option>4</option>
						<option>5</option>
						<option>6</option>
						<option>7</option>
						<option>8</option>
						<option>9</option>
						<option>10</option>
						<option>11</option>
						<option>12</option>
						<option>13</option>
						<option>14</option>
						<option>15</option>
						<option>16</option>
						<option>17</option>
						<option>18</option>
						<option>19</option>
						<option>20</option>
						<option>21</option>
						<option>22</option>
						<option>23</option>
						<option>24</option>
						<option>25</option>
						<option>26</option>
						<option>27</option>
						<option>28</option>
						<option>29</option>
						<option>30</option>
						<option>31</option>
					</select>
					Month: <select name ="month">
						<option>1</option>
						<option>2</option>
						<option>3</option>
						<option>4</option>
						<option>5</option>
						<option>6</option>
						<option>7</option>
						<option>8</option>
						<option>9</option>
						<option>10</option>
						<option>11</option>
						<option>12</option>
					</select>
					Year: <select name ="year">
						<option>1950</option>
						<option>1951</option>
						<option>1952</option>
						<option>1953</option>
						<option>1954</option>
						<option>1955</option>
						<option>1956</option>
						<option>1957</option>
						<option>1958</option>
						<option>1959</option>
						<option>1960</option>
						<option>1961</option>
						<option>1962</option>
						<option>1963</option>
						<option>1964</option>
						<option>1965</option>
						<option>1966</option>
						<option>1967</option>
						<option>1968</option>
						<option>1969</option>
						<option>1970</option>
						<option>1971</option>
						<option>1972</option>
						<option>1973</option>
						<option>1974</option>
						<option>1975</option>
						<option>1976</option>
						<option>1977</option>
						<option>1978</option>
						<option>1979</option>
						<option>1980</option>
						<option>1981</option>
						<option>1982</option>
						<option>1983</option>
						<option>1984</option>
						<option>1985</option>
						<option>1986</option>
						<option>1987</option>
						<option>1988</option>
					</select>
				</tr>
				<tr>
				</td>
				<td>
					<input type="submit" name="Submit" value="Submit">
					<input type="reset" name="Reset" value="Reset">
				</td>
			</tr>
		</table>
		
		
	</form>
</center>
</table>
	</body>
</html>

<?php
	}
	
	function create_account() {
		
		$username = $_POST['username'];
		$firstname = $_POST['firstName'];
		$surname = $_POST['lastName'];
		$initial = $_POST['initial'];
		$address_line_one = $_POST['addressLineOne'];
		$address_line_two =$_POST['addressLineTwo'];
		$city = $_POST['city'] ;
		$county = $_POST['county'] ;
		$postcode = $_POST['postcode'];
		$home_phone_number = $_POST['homePhoneNumber'] ;
		$mobile_number = $_POST['mobilePhoneNumber'] ;
		$email = $_POST['email'] ;
		$password = $_POST['password'] ;
		$password2 = $_POST['password2'] ;
		$date_of_birth = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
		
		
		//if((isset($_POST['password'])) != (isset($_POST['password2']))) error_message("Passwords do not match please re-enter them.");
		if(empty($username)) error_message("Enter your desired Username.");
		if(empty($password)) error_message("Please enter a password.");
		if(empty($firstname)) error_message("Please enter a firstname.");
		if(empty($surname)) error_message("Please enter a last name.");
		if(empty($email)) error_message("Please a enter an email.");
		//if(strlen($password < 4 )) error_message("Password too short must be more then 4 characters.");
		if(empty($password2)) error_message("Please re-enter second password for verification.");
		if(empty($email)) error_message("Enter your email.");
		if(empty($address_line_one)) error_message("Enter your address.");
		if(empty($address_line_two)) error_message("Enter the second line of your address.");
		if(empty($postcode)) error_message("Please enter your postcode.");
		if(empty($city)) error_message("Enter the city you live in.");
		if(empty($home_phone_number)) error_message("Please enter a home phone number.");
		if(empty($mobile_number)) error_message("Please enter a mobile phone number.");
		//if(empty($initial)) error_message("Please enter your title.");
		if(strlen($home_phone_number  < 11)) error_message("Invalid Home Phone Number.");
		if(strlen($mobile_number < 11)) error_message("Invalid Mobile Phone Number.");
		if(empty($date_of_birth)) error_message("Invalid Birth Date");
		
		
		if(in_use($username))
			error_message("$username is in use. Please choose a diffrent ID.");
		
		
		
		
		
		$link_id = db_connect()	or die (mysql_error());
		
		
		
		if(!$county){
			
			$query = "insert into customers (customer_id , first_name, surname, initial, address_line_one, address_line_two, city, county, postcode, home_phone_number, mobile_number, email, date_of_birth, username, password, validated, rank)
									 values (NULL , '$firstname','$surname,'$initial', '$address_line_one', '$address_line_two', '$city', NULL, '$postcode', '$home_phone_number', '$mobile_number', '$email', '$date_of_birth', '$username', '$password', NULL, NULL)";
			
			$result = mysql_query($query, $link_id) or die(mysql_error());
			echo($result);
			
			if($result)
			{
				send_validation_email();
			}
			else echo 'error';
			
		}
		
		if ($firstname && $surname && $initial && $address_line_one && $address_line_two && $city && $county && $postcode && $home_phone_number && $mobile_number && $email && $date_of_birth && $username && $password && $password2){
			
			
			$query = "insert into customers (customer_id , first_name, surname, initial, address_line_one, address_line_two, city, county, postcode, home_phone_number, mobile_number, email, date_of_birth, username, password, validated, rank)
									 values ( NULL , '$firstname','$surname,'$initial', '$address_line_one', '$address_line_two', '$city', '$county', '$postcode', '$home_phone_number', '$mobile_number', '$email', '$date_of_birth', '$username', '$password', NULL , NULL)";
			echo($query);	
			$result = mysql_query($query, $link_id) or die(mysql_error());	
			
			if($result)
			{
				send_validation_email();
			}
			else echo 'error';
			
		}
		
		function send_validation_email()
		{
			echo $firstName
				." "
				. $lastName 
				. ", You have succesfully become a customer of Funky Monkey Records. You will recieve a validation e-mail so you can activiate your account.<br><br>
						";
				$link_id = db_connect();
			$query= mysql_query("Select customer_id from customers where username = '$username'");
			$row = mysql_fetch_array($query);
			$customer_id = $row['customer_id'];
			
			$emailMessage = "<html><body>Dear ". $firstName . " " . $lastName. "<br><br>
				You have registred an account at Funky Monkey Records. In order to complete registration you have to click this activation
				link:<br><a href="validate.php?page=validate&customer_id=" . $customer_id . "">validate.php?page=validation&customer_id=" . $customer_id . "</a></body></html>";
			
			$to = $email;
			$from = "mmc01ms@hotmail.com";
			$message= $emailMessage;
			$subject = "Succesfully registred as ". $username;
			$headers = "From: $from";
			if(mail($to,$subject,$message,$headers)){
			} else{
				echo"<br><br>Failed sending an email";
				
			}
		}
	}
?>

Posted: Thu Dec 16, 2004 6:04 pm
by rehfeld
sorry im being lazy and not actually looking closely at the code.

i still havent looked closely but i saw something that will definately need to be fixed,

to see the problems put this at the very top of your script:

error_reporting(E_ALL);


variables do not exist inside functions automatically, unless they are superglobal(like $_POST and $_GET etc...)

have a read

http://www.php.net/manual/en/language.v ... .scope.php

i noticed this problem in your send_validation_email() function


also, its usually not a good idea to define one function inside of another function, as you have done by defining send_validation_email() inside create_account()

if you call create_account() twice, php will throw an error because you just defined the function twice, which you cant do. and since there is no reason you need to define the function inside of the other function, you prob should not do that.

Re: Register Form Problems

Posted: Thu Dec 16, 2004 9:54 pm
by John Cartwright

Code: Select all

<? function register_form(){
		
?>
<td>			
			<form name="register" method="post" action="register.php?action=register">
				<table>
					<tr>
						<td>* Enter Desired Username: </td>
						<td><input name="username" type="text" maxlength="10" id="username"></td>
					</tr>
					<tr>
						<td>* Enter Desired Password: </td>
						<td><input name="password" type="password" maxlength="10" id="password"></td>
					</tr>
					<tr>
						<td>* Type Password Again: </td>
						<td><input name="password2" type="password" maxlength="10" id="password2"></td>
					</tr>
					<tr>
						<td>* Email: </td>
						<td><input name="email" type="text" maxlength="40" id="email"></td>
					</tr>
					<tr>
						<td>* First Name: </td>
						<td><input name="firstName" type="text" maxlength="20" id="firstName"></td>
					</tr>
					<tr>
						<td>* Last Name: </td>
						<td><input name="lastName" type="text" maxlength="20" id="lastName"></td>
					</tr>
					<tr>
						<td>* Inital: </td>
						<td><input name="inital" type="text" maxlength="4" id="inital"></td>
					</tr>
					<tr>
						<td>* Address Line One: </td>
						<td><input name="addressLineOne" type="text" maxlength="25" id="addressLineOne"></td>
					</tr>
					<tr>
						<td>* Address Line Two: </td>
						<td><input name="addressLineTwo" type="text" maxlength="25" id="addressLineTwo"></td>
					</tr>
					<tr>
						<td>* City:  </td>
						<td><input name="city" type="text" maxlength="15" id="city"></td>
					</tr>
					<tr>
						<td>County:  </td>
						<td><input name="county" type="text" maxlength="15" id="county"></td>
					</tr>
					<tr>
						<td>* Postcode:  </td>
						<td><input name="postcode" type="text" maxlength="8" id="postcode"></td>
					</tr>
					<tr>
						<td>* Home Phone Number:  </td>
						<td><input name="homePhoneNumber" type="text" maxlength="11" id="homePhoneNumber"></td>
					</tr>
					<tr>
						<td>* Mobile Number:  </td>
						<td><input name="mobilePhoneNumber" type="text" maxlength="11" id="mobilePhoneNumber"></td>
					</tr>
					<tr>
						<td>* Date of Birth:  </td>
						<td>Day: <select name ="day">
								<option>1</option>
								<option>2</option>
								<option>3</option>
								<option>4</option>
								<option>5</option>
								<option>6</option>
								<option>7</option>
								<option>8</option>
								<option>9</option>
								<option>10</option>
								<option>11</option>
								<option>12</option>
								<option>13</option>
								<option>14</option>
								<option>15</option>
								<option>16</option>
								<option>17</option>
								<option>18</option>
								<option>19</option>
								<option>20</option>
								<option>21</option>
								<option>22</option>
								<option>23</option>
								<option>24</option>
								<option>25</option>
								<option>26</option>
								<option>27</option>
								<option>28</option>
								<option>29</option>
								<option>30</option>
								<option>31</option>
							</select>
							Month: <select name ="month">
								<option>1</option>
								<option>2</option>
								<option>3</option>
								<option>4</option>
								<option>5</option>
								<option>6</option>
								<option>7</option>
								<option>8</option>
								<option>9</option>
								<option>10</option>
								<option>11</option>
								<option>12</option>
							</select>
							Year: <select name ="year">
								<option>1950</option>
								<option>1951</option>
								<option>1952</option>
								<option>1953</option>
								<option>1954</option>
								<option>1955</option>
								<option>1956</option>
								<option>1957</option>
								<option>1958</option>
								<option>1959</option>
								<option>1960</option>
								<option>1961</option>
								<option>1962</option>
								<option>1963</option>
								<option>1964</option>
								<option>1965</option>
								<option>1966</option>
								<option>1967</option>
								<option>1968</option>
								<option>1969</option>
								<option>1970</option>
								<option>1971</option>
								<option>1972</option>
								<option>1973</option>
								<option>1974</option>
								<option>1975</option>
								<option>1976</option>
								<option>1977</option>
								<option>1978</option>
								<option>1979</option>
								<option>1980</option>
								<option>1981</option>
								<option>1982</option>
								<option>1983</option>
								<option>1984</option>
								<option>1985</option>
								<option>1986</option>
								<option>1987</option>
								<option>1988</option>
							</select>
						</tr>
						<tr>
						</td>
						<td>
							<input type="submit" name="Submit" value="Submit">
							<input type="reset" name="Reset" value="Reset">
						</td>
					</tr>
				</table>
				
				
			</form>
		</center>
</table>
	</body>
</html>

<?php
	}?>
To my understanding you cannot escape the <?php tags ?> withen a function.

Posted: Fri Dec 17, 2004 4:45 am
by mmc01ms
cheers guys sorted it out this morning it was a combo of both your solutions.