<?php
extract($_REQUEST);
$FirstName = $_POST['firstname'];
$LastName = $_REQUEST['lastname'];
$dob = $_REQUEST['dob'];
$Email = $_REQUEST['email'];
$address = $_REQUEST['address'];
$pcode = $_REQUEST['pcode'];
$username = $_REQUEST['username'];
$Password = $_REQUEST['pwd'];
$Question= $_REQUEST["Question"];
$answer = $_REQUEST['answer'];
$player = $_REQUEST['player'];
if ($player == "Annadale Player") {
if ( isset($FirstName) && isset($LastName) && isset($dob) && isset($Email) && isset($address) && isset($pcode) && isset($username) && isset($Password) && isset($Question) && isset($answer) && isset($player)) {
mysql_connect('localhost', 'root', '');
mysql_select_db( "fypannadale" );
mysql_query( "INSERT INTO members (MemberID,FirstName,LastName,dob,Email,Address,PostCode,UserName,Password,Question,Answer,Anndale_Relationship)VALUES('$FirstName','$LastName', '$dob','$Email','$Address','$Postcode','$UserName','$Password','$Question','$answer','$player')" );
echo " $FirstName $LastName has been registered with the F1 Project website";
} }
else
{ if ( isset($FirstName) && isset($LastName) && isset($dob) && isset($Email) && isset($address) && isset($pcode) && isset($username) && isset($Password) && isset($Question) && isset($answer) && isset($player)){
mysql_connect('localhost', 'root', '');
mysql_select_db( "FYPannadale" );
mysql_query( "INSERT INTO members (MemberID,FirstName,LastName,dob,Email,Address,PostCode,UserName,Password,Question,Answer,Anndale_Relationship)VALUES('$FirstName','$LastName', '$dob','$Email','$Address','$Postcode','$UserName','$Password','$Question','$Answer','$player')" );
echo " sent";
} }
<script type="text/javascript">
function CloseWindow() {
window.close();
window.opener.location.reload();
}
</script>
</head>
<body>
<div class="colmask" id="colmask"><h3>To register to the Annadale Hockey website and forum, please complete your details below. </h3>
<p>
<form id='register' action='<?= $_SERVER['PHP_SELF'] ?>' method='post' onsubmit="">
<LABEL for="firstname">First Name: </LABEL>
<INPUT type="text" name="firstname" size="20">
<LABEL for="lastname">Last Name: </LABEL>
<INPUT type="text" name="lastname" size="20"><BR><br>
Date of Birth (DOB): <input type="date" name="dob"> <LABEL for="email"> Email: </LABEL>
<INPUT type="email" name="email" size="30"><br>
<br><LABEL for="address">Address:</LABEL> <input type="text" name="address" size="50">
<LABEL for="postcode"> Postcode:</LABEL> <input type="text" name="pcode" size="10"><br><br>
<LABEL for="Username">Username:</LABEL> <input type="text" name="username"><br><br>
<LABEL for="password">Password:</LABEL> <input type="password" name="pwd"><br><br>
<LABEL for="recovery"> Recovery Question: </LABEL><input list="Questions" name="Questions"size="40">
<datalist id="Questions">
<option value="Who is your Favourite Annadale Player?">
<option value="What is the name of your Pet?">
<option value="What position do you play?">
<option value="What is your mums maiden name?">
<option value="Who inspires you?">
</datalist> <LABEL for="answer"> Answer: </LABEL>
<INPUT type="text" id="answer"><br><br>
<LABEL for="Player">Which of the following associates you to Annadale: </LABEL><br>
<input type="radio" name="player" value="Annadale Player">Annadale Player
<input type="radio" name="player" value="Supporter">Supporter
<input type="radio" name="player" value="Committee Member">Committee Member
<input type="radio" name="player" value="team manager">Team Manager
<input type="radio" name="player" value="Other">Other<br><br>
<LABEL for="mobile">Can you please submit your mobile number: </LABEL><input type="text" name="mobile" size="20"><br><br>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<INPUT type="submit" value="Submit" onclick="javascript: return CloseWindow();">
<INPUT type="reset"></p>
</form></div>
</body>
</html>
I am trying to extract the information from the form and implement it into a database I have made an if statement that i want to edit more in the future so that if a certain type of associate is picked it will send extra data to somewhere else. I have been getting a lot of PHP errors when trying to run this, where has my code went wrong?
The errors that i am getting are; Notice: Undefined index: firstname in C:\wamp\www\FinalProject\Webpages\Registration.php on line 5 Call Stack
1 0.0017 266096 {main}( ) ..\Registration.php:0
I am asking what area I need to look into to get rid of the errors. im new to this and am finding it quite difficult.
I am running it on the wampserver using myphpadmin, could that be causing any of my difficultys or is it the way my code is written?
How about literally adding name=""
in those input fields before expecting them in PHP?
<LABEL for="firstname">First Name: </LABEL>
<INPUT type="text" name="firstname" id="firstname" size="20">
<LABEL for="lastname">Last Name: </LABEL>
<INPUT type="text" name="lastname" id="lastname" size="20"><BR><br>
Date of Birth (DOB): <input type="date" name="dob"> <LABEL for="email"> Email: </LABEL>
<INPUT type="email" name="email" id="email" size="30"><br>