Need help passing Text Field to PHP Variable
Posted: Thu Aug 06, 2009 11:27 am
For the life of my I cannot figgure out why it's not working. I have tried everything to get a PHP variable to equal a text field.
This is what I have, it's a basic user account registration script.
This is what I have, it's a basic user account registration script.
Code: Select all
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>VV - Account Registration</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Account Registration</h1>
<form method="post">
<label></label>
<p>
<label>First Name
<input type="text" name="fname" id="fname" />
</label>
<label>Last Name
<input type="text" name="lname" id="lname" />
</label>
</p>
<p>
<label>User Name
<input type="text" name="uname" id="uname" />
</label><label></label>
</p>
<p>
<label>Password
<input type="password" name="pword" id="pword" />
</label>
<label>Confirm Password
<input type="password" name="confrimpword" id="confrimpword" />
</label>
</p>
<p>
<label>Email
<input type="text" name="email" id="email" />
</label>
<label>Confirm Email
<input type="text" name="confirmemail" id="confirmemail" />
</label>
</p>
<p>
<label>Secret Question</label>
<select name="question" id="question">
<option value="1">What is your mother's maiden name?</option>
<option value="2" selected="selected">What is the name of your pet?</option>
<option value="3">In what city were you born?</option>
<option value="4">What was your first car?</option>
<option value="5">What is your favorite color?</option>
<option value="6">What is your favorite movie?</option>
<option value="7">What is your favorite hobby?</option>
<option value="8">What is your dream vacation?</option>
<option value="9">What is your favorite sport?</option>
<option value="10">What is your worst pet-peeve?</option>
</select>
<label>Answer
<input type="text" name="answer" id="answer" />
</label><label></label>
</p>
</form>
<?php
$entries = array('firstname','lastname','username','password','cpassword','mail','cmail','squestion','sanswer');
$CHALLENGE_FIELD_PARAM_NAME = "verificationCode";
require_once('includes/challenge.php');
//I have tried everything: $_POST, $_REQUEST and $_GET
if(isset($_POST[$CHALLENGE_FIELD_PARAM_NAME])) {
$entries['firstname'] = $_REQUEST['fname'];
print_r($entries);
echo $entries['firstname'];
if(isChallengeAccepted($_POST[$CHALLENGE_FIELD_PARAM_NAME]) === FALSE) {
$resultMessage = "The entered verification code was not correct.";
} else {
$resultMessage = "Verification code accepted!";
}
} else {
$resultMessage = "";
}
?>
<?php
if(!empty($resultMessage)) {
echo "<p class=\"resultMessage\">{$resultMessage}</p>\n";
}
?>
<form method="post" action=".">
<fieldset>
<legend>Image Verification</legend>
<p>
<label for="subject">Enter Verification Code:</label>
<input type="text"
name="<?php echo($CHALLENGE_FIELD_PARAM_NAME) ?>"
id="<?php echo($CHALLENGE_FIELD_PARAM_NAME) ?>"
maxlength="<?php echo($CHALLENGE_STRING_LENGTH) ?>"
size="<?php echo($CHALLENGE_STRING_LENGTH) ?>"
class="inputText" />
<img src="getimage.php" />
</p>
<input type="submit" value="Submit" class="submit" />
</fieldset>
</form>
</body>
</html>