<!doctype html>
<?php
This is for setting cookies
//first failed attempt
if (isset($_POST['firstname']) != null || isset($_POST['lastname']) != null ||
isset($_POST['phonenumber']) != null || isset($_POST['email']) != null
|| isset($_POST['sulleyaddress']) != null || isset($_POST['question1']) != null
|| isset($_POST['question2']) != null || isset($_POST['question3']) != null
|| isset($_POST['question4']) != null || isset($_POST['question5']) != null) {
setcookie('firstname',$_POST['firstname']);
setcookie('lastname',$_POST['lastname']);
setcookie('phonenumber',$_POST['phonenumber']);
setcookie('email',$_POST['email']);
setcookie('sulleyaddress',$_POST['sulleyaddress']);
setcookie('question1',$_POST['question1']);
setcookie('question2',$_POST['question2']);
setcookie('question3',$_POST['question3']);
setcookie('question4',$_POST['question4']);
setcookie('question5',$_POST['question5']);
}
this is for reseting cookies
//second failed attempt
if (isset($_POST['firstname']) == null) {
setcookie('firstname','');
}
if (isset($_POST['lastname']) == null) {
setcookie('lastname','');
}
if (isset($_POST['phonenumber']) == null) {
setcookie('phonenumber','');
}
if (isset($_POST['email']) == null) {
setcookie('email','');
}
if (isset($_POST['sulleyaddress']) == null) {
setcookie('sulleyaddress','');
}
if (isset($_POST['question1']) == null) {
setcookie('question1','');
}
if (isset($_POST['question2']) == null) {
setcookie('question2','');
}
if (isset($_POST['question3']) == null) {
setcookie('question3','');
}
if (isset($_POST['question4']) == null) {
setcookie('question4','');
}
if (isset($_POST['question5']) == null) {
setcookie('question5','');
}
?>
<html>
<head>
<title>Assignment 2 - Anthony Taveras</title>
<style>#import url("css/styles.css");</style>
<!-- <link rel="stylesheet" href="styles.css" /> -->
</head>
<body>
<?php
1st step. Make the form appear. Allow user to enter and submit data.
if (!isset($_POST['submit'])) {
?>
<div id="content-container">
<div id="content">
<form name="form" id="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset>
<legend>Please Fill Out the Form</legend>
<ol>
<li><input type="text" name="firstname" value="<?php if (isset($_COOKIE['firstname'])) {echo $_COOKIE['firstname'];} ?>" ><label> First Name</label></li>
<li><input type="text" name="lastname" value="<?php if (isset($_COOKIE['lastname'])) {echo $_COOKIE['lastname'];} ?>" ><label> Last Name</label></li>
<li><input type="text" name="phonenumber" value="<?php if (isset($_COOKIE['phonenumber'])) {echo $_COOKIE['phonenumber'];} ?>" ><label> Phone Number</label></li>
<li><input type="text" name="email" value="<?php if (isset($_COOKIE['email'])) {echo $_COOKIE['email'];} ?>" ><label> Email</label></li>
<li><input type="text" name="sulleyaddress" value="<?php if (isset($_COOKIE['sulleyaddress'])) {echo $_COOKIE['sulleyaddress'];} ?>" ><label> Sulley Address</label></li>
</ol>
</fieldset>
<fieldset>
<legend>Please answer these questions</legend>
<ol>
<li class="question"><input type="text" name="question1" value="<?php if (isset($_COOKIE['question1'])) {echo $_COOKIE['question1'];} ?>" ><label> What is your favorite color?</label></li>
<li class="question"><input type="text" name="question2" value="<?php if (isset($_COOKIE['question2'])) {echo $_COOKIE['question2'];} ?>" ><label> Where were you born?</label></li>
<li class="question"><input type="text" name="question3" value="<?php if (isset($_COOKIE['question3'])) {echo $_COOKIE['question3'];} ?>" ><label> What is your favorite food?</label></li>
<li class="question"><input type="text" name="question4" value="<?php if (isset($_COOKIE['question4'])) {echo $_COOKIE['question4'];} ?>" ><label> What is your favorite movie?</label></li>
<li class="question"><input type="text" name="question5" value="<?php if (isset($_COOKIE['question5'])) {echo $_COOKIE['question5'];} ?>" ><label> What is your favorite book?</label></li>
<li><input type="submit" name="submit" value="Submit" /></li>
</ol>
</fieldset>
</form>
</div>
</div>
2nd step once submitted user can view responses
<?php
} elseif (isset($_POST['submit'])) {
?>
<!--=============================================Form Preview--------------------------------------->
<div id="content-container">
<div id="content">
<h1> Here's what you put down</h1>
<p> First Name: <?php print $_POST['firstname']; ?> </p>
<p> Last Name: <?php print $_POST['lastname']; ?> </p>
<p> Phone Number: <?php print $_POST['phonenumber']; ?> </p>
<p> Email: <?php print $_POST['email']; ?> </p>
<p> Sulley Address: <?php print $_POST['sulleyaddress']; ?> </p>
<p class="question"> What is your favorite color? <?php print $_POST['question1']; ?> </p>
<p class="question"> Where were you born? <?php print $_POST['question2']; ?> </p>
<p class="question"> What is your favorite food? <?php print $_POST['question3']; ?> </p>
<p class="question"> What is your favorite movie? <?php print $_POST['question4']; ?> </p>
<p class="question"> What is your favorite book? <?php print $_POST['question5']; ?> </p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="edit" value="Edit" />
</form>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="confirm" value="Finish" />
</form>
</div>
</div>
This is the problem area. This last step of the if else statement will not work properly. I'm not sure why. Any help is needed. Thanks.
<?php } elseif (isset($_POST['confirm'])) {
?>
<!--=============================================Form Confirmed--------------------------------------->
<div id="content-container">
<div id="content">
<p> Thank you, your data has been submitted</p>
</div>
</div>
<?php }
?>
</body>
</html>
You've got two form tags. One has the submit, one the hidden field.
You're not passing the variable therefore.
Try troubleshooting!
echo '<pre>';
print_r($_POST);
I would guess that it is because the forms are empty.
Try:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input id='placeholder' name='placeholder' type='text' value='placeholder' hidden>
<input type="submit" name="confirm" value="Finish" />
</form>
Related
I am studying an example of filling out a form.
https://github.com/sitepoint-editors/basic-form-validation-with-php/blob/main/index.php
And I can't figure out how to properly separate HTML and PHP code if I need to get the output of incorrectly filled fields on the same page.
I want to get something like that:
index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fruit Survey</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h1>The World of Fruit</h1>
<h2>Fruit Survey</h2>
<form class="wrapper" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<label for="name">Name</label>
<div>
<input type="text"
name="name"
id="name"
value="<?php echo htmlspecialchars($values['name']);?>">
<?php if (in_array('name', $errors)): ?>
<span class="error">Missing</span>
<?php endif; ?>
</div>
<label for="address">Address</label>
<div>
<input type="text"
name="address"
id="address"
value="<?php echo htmlspecialchars($values['address']);?>">
<?php if (in_array('address', $errors)): ?>
<span class="error">Missing</span>
<?php endif; ?>
</div>
<label for="email">Email</label>
<div>
<input type="text"
name="email"
id="email"
value="<?php echo htmlspecialchars($values['email']);?>">
<?php if (in_array('email', $errors)): ?>
<span class="error">Missing</span>
<?php endif; ?>
</div>
<div class="field-label">How many pieces of fruit do you eat per day?</div>
<div>
<label>
<input type="radio"
name="howMany"
<?php if (isset($values['howMany']) && $values['howMany'] == "zero") echo "checked"; ?>
value="zero">
0
</label>
<label>
<input type="radio"
name="howMany"
<?php if (isset($values['howMany']) && $values['howMany'] == "one") echo "checked"; ?>
value="one">
1
</label>
<label>
<input type="radio"
name="howMany"
<?php if (isset($values['howMany']) && $values['howMany'] == "two") echo "checked"; ?>
value="two">
2
</label>
<label>
<input type="radio"
name="howMany"
<?php if (isset($values['howMany']) && $values['howMany'] == "twoplus") echo "checked"; ?>
value="twoplus">
More than 2
</label>
<?php if (in_array('howMany', $errors)): ?>
<span class="error">Missing</span>
<?php endif; ?>
</div>
<label for="favoriteFruit">My favourite fruit</label>
<div>
<select name="favoriteFruit[]" id="favoriteFruit" size="4" multiple="">
<?php
$options = ["apple", "banana", "plum", "pomegranate", "strawberry", "watermelon"];
foreach ($options as $option) {
printf(
'<option value="%s" %s>%s</option>',
$option,
(in_array($option, $values['favoriteFruit'])) ? "selected" : '',
ucfirst($option)
);
}
?>
</select>
<?php if (in_array('favoriteFruit', $errors)): ?>
<span class="error">Missing</span>
<?php endif; ?>
</div>
<label for="brochure">Would you like a brochure?</label>
<div>
<input type="checkbox"
name="brochure"
id="brochure"
<?php if (isset($values['brochure']) && $values['brochure'] == "Yes") echo "checked"; ?>
value="Yes">
</div>
<div>
<input type="submit" name="submit" value="Submit">
</div>
</form>
</body>
</html>
process.php
<?php
$errors = [];
$fields = ['name', 'address', 'email', 'howMany', 'favoriteFruit', 'brochure'];
$optionalFields = ['brochure'];
$values = [];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
foreach ($fields as $field) {
if (empty($_POST[$field]) && !in_array($field, $optionalFields)) {
$errors[] = $field;
} else {
$values[$field] = $_POST[$field];
}
}
if (empty($errors)) {
foreach ($fields as $field) {
if ($field === "favoriteFruit") {
printf("%s: %s<br />", $field, var_export($_POST[$field], TRUE));
} else {
printf("%s: %s<br />", $field, $_POST[$field]);
}
}
exit;
}
}
//MYSQL
require_once('db-connect.php');
$statement = $mysqli->prepare("INSERT INTO users_data (name, address, email, howMany, favoriteFruit, brochure) VALUES(?, ?, ?, ?, ?, ?)");
$statement->bind_param('ssssss', $name, $address, $email, $howMany, $favoriteFruit, $brochure);
if($statement->execute()){
print "Hello, " . $name . "!, your request has been sent!";
}else{
print $mysqli->error;
}
?>
But for that I need to replace <form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?> with <form method="post" action="process.php">
But then field validation and error output in the form does not work.
like this man
php:
<?php
$errors = [];
$fields = ['name', 'address', 'email', 'howMany', 'favoriteFruit', 'brochure'];
$optionalFields = ['brochure'];
$values = [];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
foreach ($fields as $field) {
if (empty($_POST[$field]) && !in_array($field, $optionalFields)) {
$errors[] = $field;
} else {
$values[$field] = $_POST[$field];
}
}
And what ever you put as a value in html forms
like this
<label for="favoriteFruit">My favorite fruit</label>
<div>
<select name="favoriteFruit[]" id="favoriteFruit" size="4" multiple="">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="plum">Plum</option>
<option value="pomegranate">Pomegranate</option>
<option value="strawberry">Strawberry</option>
<option value="watermelon">Watermelon</option>
</select>
</div>
<label>
<input type="radio" name="howMany" value="zero"> 0
</label>
<label>
<input type="radio" name="howMany" value="one"> 1
</label>
<label>
<input type="radio" name="howMany" value="two"> 2
</label>
<label>
<input type="radio" name="howMany" value="twoplus"> More than 2
</label>
<label for="name">Name</label>
<div>
<input type="text" name="name" id="name" value="">
</div>
<label for="address">Address</label>
<div>
<input type="text" name="address" id="address" value="">
</div>
<label for="email">Email</label>
<div>
<input type="text" name="email" id="email" value="">
</div>
Here i have numerous input fields in a form, which are working perfectly. And now, i want to add new input boxes and their labels according to property_type , Which is already exist on this page.
Now, Kindly Suggest me How can i add new fields in that form.
Here is my Form Code
<div class="dashboard_price_left">
<h3>
<?php
if ($this->lang->line('BasePrice') != '') {
echo stripslashes($this->lang->line('BasePrice'));
} else
echo "Base Price";
?>
</h3>
<p>
<?php
if ($this->lang->line('Atitleandsummary') != '') {
echo stripslashes($this->lang->line('Atitleandsummary'));
} else
echo "Set weekly or monthly price guests will see for your listing.";
?>
</p>
</div>
<?php
if ($listDetail->row()->home_type == 'Office') {
} else if ($listDetail->row()->home_type == 'House') {
}
?>
<form id="pricelist" name="pricelist" action="site/product/savePriceList" method="post">
<div class="dashboard_price_right">
<label><?php
if ($this->lang->line('Pernight') != '') {
echo stripslashes($this->lang->line('Pernight'));
} else
echo "Per night";
?>
</label>
<div class="amoutnt-container">
<?php if ($currentCurrency == '') { ?>
<span class="WebRupee"><?php echo $currencyDetail->row()->currency_symbols; ?></span>
<?php } else { ?>
<span class="WebRupee"><?php echo $currentCurrency; ?></span>
<?php } ?>
<input type="text" id="price" value="<?php
if ($listDetail->row()->price != '0.00') {
echo intval($listDetail->row()->price);
}
?>" class="per_amount_scroll" name="price" onkeypress="return onlyNumbersWithDot(event);" onchange="javascript:Detailview(this,<?php echo $listDetail->row()->id; ?>, 'price');" />
<input type="hidden" id="id" name="id" value="<?php echo $listDetail->row()->id; ?>" />
</div>
<div class="dashboard_currency">
<label><?php
if ($this->lang->line('Currency') != '') {
echo stripslashes($this->lang->line('Currency'));
} else
echo "Currency";
?>
</label>
<div class="select select-large select-block">
<select name="currency" id="currency" onchange="javascript:Detailview(this,<?php echo $listDetail->row()->id; ?>, 'currency');get_currency_symbol(this)" >
<!--<option value="">select</option>-->
<?php foreach ($currencyDetail->result() as $currency) { ?>
<option value="<?php echo $currency->currency_type; ?>" <?php if ($listDetail->row()->currency == $currency->currency_type) echo 'selected="selected"'; ?>><?php echo $currency->currency_type; ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
</form>
Here is a pic of my Property prices form
Note: There are two types of property that are following:
1. Office
2. House
on the basis of these property, I want to add more fields in my form.
Please suggest me, Thanks in Advance :)
you can change it base on conditon and pass hidden field which indicates you office or house.
<?php
if ($listDetail->row()->home_type == 'Office')
{
<input type="hidden" name="home_type" value="Office" />
<input type="text" name="per_day" value="" />
<input type="text" name="half_day" value="" />
<input type="text" name="per_hour" value="" />
}
else if ($listDetail->row()->home_type == 'House')
{
<input type="hidden" name="home_type" value="House" />
<input type="text" name="per_night" value="" />
<input type="text" name="per_day" value="" />
<input type="text" name="per_hour" value="" />
}
?>
I want to check form fields on PHP. I have tried but I don't get any message. I am not sure why.
I use mongodb database, and I'm new in PHP.
My PHP code so far:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="post">
<h3> Name :</h3>
<p>
<input type="text" name="username" id="title/">
</p>
<h3>Title :</h3>
<p>
<input type="text" name="title" id="title/">
</p>
<h3>Content :</h3>
<textarea id="content" name="content" rows="20" cols="100"></textarea>
<p>
<br/>
<input type="submit" name="btn_submit" value="Save"/>
</p></form>
</center>
<?php
if (isset($_POST['btn_submit']))
{
$title = $_POST['title'];
$content = $_POST['content'];
if (!isset($title) || empty($title))
{
echo " <h2> check title ! </h2>";
}
if (!isset($content) || empty($content))
{
echo " <h2> check content ! </h2>";
}
}
?>
<?php
else: ?>
<p>
success. _id:<?php echo $article['_id']; ?>.
<a href="blogpost.php">
write other articles ?</a>
</p>
<?php endif; ?>
Just reviewed your code. I think it has a few problems, but the main one is in the if-else sequence.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="post">
<h3> Name :</h3>
<p>
<input type="text" name="username" id="title/">
</p>
<h3>Title :</h3>
<p>
<input type="text" name="title" id="title/">
</p>
<h3>Content :</h3>
<textarea id="content" name="content" rows="20" cols="100"></textarea>
<p>
<br/>
<input type="submit" name="btn_submit" value="Save"/>
</p></form>
</center>
<?php
if (isset($_POST['btn_submit']))
{
$title = $_POST['title'];
$content = $_POST['content'];
if (!isset($title) || empty($title))
{
echo " <h2> check title ! </h2>";
}
if (!isset($content) || empty($content))
{
echo " <h2> check content ! </h2>";
}
?>
<?php } else { ?>
<p>
<?php echo $article['_id']; ?>.
<a href="blogpost.php">
write other articles ?</a>
</p>
<?php } ?>
You have syntax error in if else statement and also there is undefined varibale $article['_id']. Where do you get that value from? Other than that the code is fine. Here is the updated code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="post">
<h3> Name :</h3>
<p>
<input type="text" name="username" id="title/">
</p>
<h3>Title :</h3>
<p>
<input type="text" name="title" id="title/">
</p>
<h3>Content :</h3>
<textarea id="content" name="content" rows="20" cols="100"></textarea>
<p>
<br/>
<input type="submit" name="btn_submit" value="Save"/>
</p></form>
</center>
<?php
if (isset($_POST['btn_submit']))
{
$title = $_POST['title'];
$content = $_POST['content'];
if (!isset($title) || empty($title))
{
echo " <h2> check title ! </h2>";
}
else if (!isset($content) || empty($content))
{
echo " <h2> check content ! </h2>";
}
else
{
echo "<p>Success!!! <a href='blogpost.php'>
write other articles ?</a> </p>";
}
}
?>
I have the following code:
<?php $radioSwitch = of_get_option('radio_switch');
if ($radioSwitch == "true") { ?>
<!-- radio switch -->
<div class="row switches clearfix">
<input type="radio" name="switch" id="switch1" value="<?php echo of_get_option('switch1'); ?>" /><label for="switch1" class="field"><?php echo of_get_option('switch1'); ?></label>
<input type="radio" name="switch" id="switch2" value="<?php echo of_get_option('switch2'); ?>" /><label for="switch2" class="field"><?php echo of_get_option('switch2'); ?></label>
</div>
<?php } ?>
................................................................................
<?php
$datePicker1 = of_get_option('datepicker1');
$datePicker2 = of_get_option('datepicker2');
if (($datePicker1 == "true") || ($datePicker2 == "true")) { ?>
<div class="row clearfix">
<?php if ($datePicker1 == "true") { ?>
<!-- datepicker 1 -->
<input type="text" id="dateFrom" name="<?php echo of_get_option('datepicker1_text'); ?>" value="<?php echo of_get_option('datepicker1_text'); ?>" tabindex="6" />
<label class="error" for="dateFrom" id="dateFrom_error">Selectați data.</label>
<?php } ?>
<?php if ($datePicker2 == "true") { ?>
<!-- datepicker 2 -->
<input type="textarea" id="dateTo" name="<?php echo of_get_option('datepicker2_text'); ?>" value="<?php echo of_get_option('datepicker2_text'); ?>" tabindex="7" />
<label class="error" for="dateTo" id="dateTo_error">Selectați data.</label>
<?php } ?>
</div>
<?php } ?>
If radio button "switch1" is selected, only "$datepicker1" must be true and "$datepicker2" must be false, and if radio button "switch2" is selected, both "$datepicker1" and "$datepicker2" must be true. Anyone could help me?
PHP is a server-side language which is parsed on the server. You cannot modify variables of PHP on the browser.
Try submitting the radio button options as a form into a PHP page.
Part of my PHP form is not displaying with jQuery Mobile. The form seems to cut off after <input name="F_Payment_Preference" type="hidden" id="F_Payment_Preference" value="check"> and then it restarts after </form>. My form seems to function and display correctly without jQuery Mobile. I am not showing the head of the page (it's in a separate file), but I don't think that is necessary.
">
<form action="<? echo $_SERVER["PHP_SELF"] ?>" method="post" name="form1" id="form1" onsubmit="return CheckData();">
<h1><? echo PERSONAL_INFORMATION
?></h1><?
if ($show_sponsor == 1) {
Get_Sponsor_Cookie('name');
}
?>
<div>
*<? echo REQUIRED_FIELDS
?>
</div>
<div>
<label for="F_First_Name"><? echo FIRST_NAME
?>*</label>
<input name="F_First_Name" type="text" value="<? echo $F_First_Name ?>" maxlength="50">
<div id="divfname" style="display:none;">
<? echo JV_ENTER_FIRST_NAME
?>
</div>
</div>
<div>
<label for="F_Last_Name"><? echo LAST_NAME ?>*</label>
<input name="F_Last_Name" type="text" value="<? echo $F_Last_Name ?>" maxlength="50">
</div>
<div id="divlname" style="display:none">
<? echo JV_ENTER_LAST_NAME
?>
</div>
<?
if ($require_company == 1 || $require_company == 2)
{
?>
<div>
<label for="F_Company_Name"><? echo ROW_COMPANY ?>
<?
if ($require_company == 2) { echo "*";
}
?></label>
<input name="F_Company_Name" type="text" value="<? echo $F_Company_Name ?>" maxlength="100">
</div>
<div id="divcmp" style="display:none">
<? echo ENTER_COMPANY
?>
</div>
<?
}
if ($require_address_1 == 1 || $require_address_1 == 2)
{
?>
<div>
<label for="F_Address_1"><? echo ADDRESS_1
?><?
if ($require_address_1 == 2) { echo "*";
}
?></label>
</div>
<input name="F_Address_1" type="text" value="<? echo $F_Address_1 ?>" maxlength="200">
<div id="divaddr1" style="display:none">
<? echo JV_ENTER_ADDRESS_1
?>
</div>
<?
}
if ($require_address_2 == 1 || $require_address_2 == 2)
{
?>
<div>
<label for="F_Address_2"><? echo ADDRESS_2
?><?
if ($require_address_2 == 2) { echo "*";
}
?></label>
<input name="F_Address_2" type="text" value="<? echo $F_Address_2 ?>" maxlength="200">
</div>
<div id="divaddr2" style="display:none">
<? echo JV_ENTER_ADDRESS_2
?>
</div>
<?
}
if ($require_city == 1 || $require_city == 2)
{
?>
<div>
<label for="F_City"><? echo ROW_CITY
?><?
if ($require_city == 2) { echo "*";
}
?></label>
<input name="F_City" type="text" value="<? echo $F_City ?>" maxlength="50">
</div>
<div id="divcity" style="display:none">
<? echo JV_ENTER_CITY
?>
</div>
<?
}
if ($require_ste == 1 || $require_state == 2)
{
?>
<div>
<label for="F_State"><? echo ROW_STATE
?><?
if ($require_state == 2) { echo "*";
}
?></label>
<input name="F_State" type="text" value="<? echo $F_State ?>" maxlength="50">
</div>
<div id="divstate" style="display:none">
<? echo JV_ENTER_STATE
?>
</div>
<?
}
if ($require_country == 1 || $require_country == 2)
{
?>
<div>
<label><? echo ROW_COUNTRY
?><?
if ($require_country == 2) { echo "*";
}
?></label>
<?
if (!isset($_POST['F_Country'])) { $F_Country = '';
} else { $F_Country = $_POST['F_Country'];
} Country_Menu_Members($F_Country);
?>
</div>
<?
}
if ($require_zip == 1 || $require_zip == 2)
{
?>
<div>
<label for="F_Zip"><? echo ZIP_CODE
?><?
if ($require_zip == 2) { echo "*";
}
?></label>
<input name="F_Zip" type="text" value="<? echo $F_Zip ?>" maxlength="25" />
</div>
<div id="divzip" style="display:none">
<? echo JV_ENTER_ZIP
?>
</div>
<?
}
if ($require_phone == 1 || $require_phone == 2)
{
?>
<div>
<label for="F_Phone"><? echo PHONE
?><?
if ($require_phone == 2) { echo "*";
}
?></label>
<input name="F_Phone" type="text" value="<? echo $F_Phone ?>" maxlength="25" />
</div>
<div id="divphone" style="display:none">
<? echo JV_ENTER_PHONE
?>
</div>
<?
}
if ($require_fax == 1 || $require_fax == 2)
{
?>
<div>
<label for="F_Fax"><? echo FAX
?><?
if ($require_fax == 2) { echo "*";
}
?></label>
<input name="F_Fax" type="text" value="<? echo $F_Fax ?>" maxlength="25" />
</div>
<div id="divfax" style="display:none">
<? echo ENTER_FAX
?>
</div>
<?
}
if ($require_check_name == 1 || $require_check_name == 2)
{
?>
<div>
<label for="F_Check_Name"><? echo CHECK_NAME
?><?
if ($require_check_name == 2) { echo "*";
}
?></label>
<input name="F_Check_Name" type="text" value="<? echo $F_Check_Name ?>" maxlength="50" />
</div>
<div id="divcheckname" style="display:none">
<? echo ENTER_CHECK_NAME
?>
</div>
<?
}
if ($show_payment == 1)
{
?>
<div>
<label for="F_Payment_Preference"><? echo PAYMENT_PREFERENCE
?>*</label>
<? Link_Payment_Preferences();?>
<? } else {?>
<input name="F_Payment_Preference" type="hidden" id="F_Payment_Preference" value="check" />
</div>
<?
}
if ($require_tax_id == 1 || $require_tax_id == 2)
{
?>
<div>
<label for="F_Tax_ID"><? echo TAX_ID
?><?
if ($require_tax_id == 2) { echo "*";
}
?></label>
<input name="F_Tax_ID" type="text" value="<? echo $F_Tax_ID ?>" maxlength="50" />
</div>
<div id="divtax" style="display:none">
<? echo INVALID_TAX_ID
?>
</div>
<?
}
?> <h2><? echo USER_ACCOUNT_INFORMATION
?></h2>
<?
if ($require_username == 1 || $require_username == 2)
{
?>
<div>
<label for="F_User_Name"><? echo USERNAME
?>
<?
if ($require_username == 2) { echo "*";
}
?></label>
<input name="F_User_Name" type="text" value="<? echo $F_User_Name ?>" maxlength="20" />
</div>
<div id="divuname" style="display:none">
<? echo JV_ENTER_USERNAME
?>
</div>
<?
}
if ($require_password == 1 || $require_password == 2)
{
?>
<div>
<label for="F_Password"><? echo PASSWORD
?><?
if ($require_password == 2) { echo "*";
}
?></label>
<input name="F_Password" type="password" value="<? echo $F_Password ?>" maxlength="12">
</div>
<div id="divpw" style="display:none">
<? echo JV_ENTER_PASSWORD
?>
</div>
<div>
<label for="F_Password_2"><? echo CONFIRM_PASSWORD
?><?
if ($require_password == 2) { echo "*";
}
?></label>
<input name="F_Password_2" type="password" id="password2" value="<? echo $F_Password_2 ?>" maxlength="12">
</div>
<div id="divcpw" style="display:none">
<? echo JV_ENTER_CONFIRM_PASSWORD
?>
</div>
<?
}
?>
<div>
<label for="F_Primary_Email"><? echo EMAIL_ADDRESS
?>*</label>
<input name="F_Primary_Email" type="email" value="<? echo $F_Primary_Email ?>" maxlength="50">
</div>
<div id="divemail" style="display:none">
<? echo JV_ENTER_EMAIL
?>
</div>
<?
if ($require_paypal_email == 1 || $require_paypal_email == 2)
{
?>
<div>
<label for="F_Paypal_Email"><? echo PAYPAL_EMAIL
?><?
if ($require_paypal_email == 2) { echo "*";
}
?></label>
<input name="F_Paypal_Email" type="text" value="<? echo $F_Paypal_Email ?>" maxlength="50">
</div>
<div id="divpaypal" style="display:none">
<? echo JV_ENTER_PAYPAL
?>
</div>
<?
}
if ($require_stormpay_email == 1 || $require_stormpay_email == 2)
{
?>
<div>
<label for="F_Stormpay_Email"><? echo STORMPAY_EMAIL
?><?
if ($require_stormpay_email == 2) { echo "*";
}
?></label>
<input name="F_Stormpay_Email" type="text" value="<? echo $F_Stormpay_Email ?>" maxlength="50">
</div>
<div id="divstormpay" style="display:none">
<? echo JV_STORMPAY_EMAIL
?>
</div>
<?
}
if ($require_safepay_email == 1 || $require_safepay_email == 2)
{
?>
<div>
<label for="F_Safepay_Email"><? echo SAFEPAY_EMAIL
?><?
if ($require_stormpay_email == 2) { echo "*";
}
?></label>
<input name="F_Safepay_Email" type="text" value="<? echo $F_Safepay_Email ?>" maxlength="50">
</div>
<div id="divsafepay" style="display:none">
<? echo JV_SAFEPAY_EMAIL
?>
</div>
<?
}
if ($require_moneybookers_email == 1 || $require_moneybookers_email == 2)
{
?>
<div>
<label for="F_Moneybookers_Email"><? echo MONEYBOOKERS_EMAIL
?><?
if ($require_moneybookers_email == 2) { echo "*";
}
?></label>
<input name="F_Moneybookers_Email" type="text" value="<? echo $F_Moneybookers_Email ?>" maxlength="50">
</div>
<div id="divmoneybookers" style="display:none">
<? echo JV_MONEYBOOKERS_EMAIL
?>
</div>
<?
}
if ($require_alertpay_email == 1 || $require_alertpay_email == 2)
{
?>
<div>
<label for="F_Alertpay_Email"><? echo ALERTPAY_EMAIL
?><?
if ($require_alertpay_email == 2) { echo "*";
}
?></label>
<input name="F_Alertpay_Email" type="text" value="<? echo $F_Alertpay_Email ?>" maxlength="50">
</div>
<div id="divalertpay" style="display:none">
<? echo JV_ALERTPAY_EMAIL
?>
</div>
<?
}
if ($require_egold_id == 1 || $require_egold_id == 2)
{
?>
<div>
<label for="F_Egold_Id"><? echo EGOLD_ID
?><?
if ($require_egold_id == 2) { echo "*";
}
?></label>
<input name="F_Egold_Id" type="text" value="<? echo $F_Egold_Id ?>" maxlength="50">
</div>
<div id="divegold" style="display:none">
<? echo JV_EGOLD_ID
?>
</div>
<?
}
if ($require_bank_transfer == 1 || $require_bank_transfer == 2)
{
?>
<div>
<label for="F_Bank_Transfer"><? echo BANK_TRANSFER
?><?
if ($require_bank_transfer == 2) { echo "*";
}
?></label>
<textarea name="F_Bank_Transfer" cols="30" rows="3"><? echo $F_Bank_Transfer ?></textarea>
</div>
<div id="divbanktransfer" style="display:none">
<? echo JV_BANK_TRANSFER
?>
</div>
<?
}
if ($require_sponsor == 1)
{
if (empty($_COOKIE['jrox']))
{
?>
<div>
<label for="F_Sponsor"><? echo REFERRAL_CODE
?>*</label>
<input name="F_Sponsor" type="text" value="<? echo $F_Sponsor ?>" maxlength="25">
</div>
<?
}
else
{
?>
<input name="F_Sponsor" type="hidden" id="F_Sponsor" value="<? echo $F_Sponsor ?>">
<div>
<?
}
}
else
{
?>
<input name="F_Sponsor" type="hidden" id="F_Sponsor" value="<? echo $F_Sponsor ?>">
</div>
<?
}
if ($require_website_url == 1 || $require_website_url == 2)
{
?>
<div>
<label><? echo WEBSITE_URL
?><?
if ($require_website_url == 2) { echo "*";
}
?></label>
<input name="F_Web_Site" type="text" value="<? echo $F_Web_Site ?>" maxlength="100">
</div>
<div id="divweb" style="display:none">
<? echo INVALID_WEBSITE_ADDRESS
?>
</div>
<?
}
if ($enable_custom_1 == 1 || $enable_custom_1 == 2)
{
?>
<div>
<label><? echo $custom_field_1
?><?
if ($enable_custom_1 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_1" type="text" value="<? echo $F_Custom_Value_1 ?>" maxlength="255">
</div>
<div id="divcf1" style="display:none">
<? echo ROW_ENTER." ".$custom_field_1
?>
</div>
<?
}
if ($enable_custom_2 == 1 || $enable_custom_2 == 2)
{
?>
<div>
<label><? echo $custom_field_2
?><?
if ($enable_custom_2 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_2" type="text" value="<? echo $F_Custom_Value_2 ?>" maxlength="255">
</div>
<div id="divcf2" style="display:none">
<? echo ROW_ENTER." ".$custom_field_2
?>
</div>
<?
}
if ($enable_custom_3 == 1 || $enable_custom_3 == 2)
{
?>
<div>
<label><? echo $custom_field_3
?><?
if ($enable_custom_3 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_3" type="text" value="<? echo $F_Custom_Value_3 ?>" maxlength="255">
</div>
<div id="divcf3" style="display:none">
<? echo ROW_ENTER." ".$custom_field_3
?>
</div>
<?
}
if ($enable_custom_4 == 1 || $enable_custom_4 == 2)
{
?>
<div>
<label><? echo $custom_field_4
?> <?
if ($enable_custom_4 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_4" type="text" value="<? echo $F_Custom_Value_4 ?>" maxlength="255">
</div>
<div id="divcf4" style="display:none">
<? echo ROW_ENTER." ".$custom_field_4
?>
</div>
<?
}
if ($enable_custom_5 == 1 || $enable_custom_5 == 2)
{
?>
<div>
<label><? echo $custom_field_5
?><?
if ($enable_custom_5 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_5" type="text" value="<? echo $F_Custom_Value_5 ?>" maxlength="255">
</div>
<div id="divcf5" style="display:none">
<? echo ROW_ENTER." ".$custom_field_5
?>
</div>
<?
}
if ($enable_membership_payment == 2)
{
?>
<div>
<? echo MEMBERSHIP_FULL_AMOUNT
?>
<? echo $membership_full_amount
?>
<div>
<label><? echo SELECT_PAYMENT_TYPE
?></label>
</div>
<? List_Processor_Options();?>
<?
}
if ($enable_custom_html == 1 )
{
?>
<div>
<? echo $custom_html ?>
</div>
<?
}
if ($require_tos == 1 || $require_tos == 2)
{
?>
<div>
<input name="F_TOS" type="checkbox" id="F_TOS" value="1">
<?
if ($require_tos == 2) { echo "checked";
}
?>
</div>
<div>
<label><? echo ACCEPT_AND_WILL_FOLLOW ?></label><a href="<? echo MEMBERS_HOME_BASE_URL.HOME_BASE_AFFILIATE_DIRECTORY.'/index.php?req=tos&pid=$pid' ?>" target="_blank" data-role="dialog"><? echo TERMS_OF_SERVICE
?></a>
</div>
<?
}
?>
</div>
<div>
<input type="submit" name="Submit" value="<? echo SUBMIT?>">
<input name="req" type="hidden" id="req" value="newaccount">
<input name="action" type="hidden" id="action" value="signup">
<input name="pid" type="hidden" id="pid" value="<? echo $pid ?>">
</div>
</form>
<?
}
?>
It appears to be bad HTML formatting. I think you would be ok if you restructure the if block just above the problem area. This is what I see:
...
if ($show_payment == 1)
{
?>
<div>
<label>...</label>
<? Link_Payment_Preferences();?>
<? } else {?>
<input name="F_Payment_Preference" type="hidden" id="F_Payment_Preference" value="check" />
</div>
<?
}
...
Do you see the problem? If $show_payment == 1, you start a <div> but do not close it. If $show_payment != 1 (else) then you close an unopened <div>
UPDATE
So the answer is to better format your code:
...
if ($show_payment == 1)
{
?>
<div>
<label>...</label>
<? Link_Payment_Preferences();?>
</div>
<? } else {?>
<div>
<label>...</label>
<input name="F_Payment_Preference" type="hidden" id="F_Payment_Preference" value="check" />
</div>
<?
}
...
See the difference? We have to close that div in either branch your logic takes. Otherwise, jQuery Mobile may render some unexpected results as the DOM is not properly constructed.
Hope this helps.