double serialize function checkbook in php - php

I have 3 checkbook with 3 option answer every checkbook. I'm saving every checkbook using serialize, but I can't save the data if the check book has 1 more answer.
<?php if( ! empty($questiontype)): ?>
<label>Answer Type</label><br>
<label>A</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline" >
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == #$meta['answertype'][0][0]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<label>B</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline">
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == #$meta['answertype'][1][1]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<label>C</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline">
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == #$meta['answertype'][2][2]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<?php endif; ?>

Related

Get checked on checkbox select from database

im working to edit data, and I retrieve data from the database. but when I tried to retrieve data in the form of a checkbox implementation, I experienced a loss in doing so. My checkbox can't check auto based on the data in my database.
<div class="form-group">
<label>Fasilitas: </label>
<div class="row skin skin-flat">
<div class="col-md-4 col-sm-12">
<?php
$gfasis = (explode(", ",$i['gedung_fasilitas']));
$fasi = [
1=>
"Catering",
"Dekorasi Pelaminan",
"Photo & Video Akad Resepsi",
"Album Kolase",
"Makeup",
"Mc / Pembawa Acara",
"Weeding Organizer",
"Entertainment",
"Pakaian Pengantin",
"Ruang Full AC",
"Meja VIP",
"Lighting",
"Lcd Proyektor",
"Tari Tradisional",
"Photo Both",
"Seragam Keluarga",
"Seragam Orang tua",
"Meja Akad nikah",
"Buku Tamu",
"Kotak Amplop",
"Box Hantaran",
"Free Menginap di Hotel",
"Qoori Akad / Resepsi",
"Ruang Hias",
"Raung Tunggu Pengantin",
"Beskap Pengantin",
"Rental Mobil Pengantin",
"Kursi sofa",
"Meja makan prasmanan",
"Gazebo Pintu Masuk",
"Red Carpet"
];
for($kk=1; $kk<=11; $kk++) {
?>
<fieldset>
<input type="checkbox" id="<?= $kk; ?>" name="fasilitas[]" value="<?= $kk; ?>">
<label for="<?= $kk; ?>"><?= $fasi[$kk]; ?></label>
</fieldset>
<?php } ?>
</div>
<div class="col-md-4 col-sm-12">
<?php
for($kk=12; $kk<=21; $kk++) {
?>
<fieldset>
<input type="checkbox" id="<?= $kk; ?>" name="fasilitas[]" value="<?= $kk; ?>">
<label for="<?= $kk; ?>"><?= $fasi[$kk]; ?></label>
</fieldset>
<?php } ?>
</div>
<div class="col-md-4 col-sm-12">
<?php
for($kk=22; $kk<=31; $kk++) { ?>
<fieldset>
<input type="checkbox" id="<?= $kk; ?>" name="fasilitas[]" value="<?= $kk; ?>">
<label for="<?= $kk; ?>"><?= $fasi[$kk]; ?></label>
</fieldset>
<?php } ?>
</div>
</div>
</div>
as you can see my checkbox still 0, this must be got checked
when i add this code
for($kk=1; $kk<=11; $kk++) { ?>
<fieldset>
<input type="checkbox" id="<?= $kk; ?>" name="fasilitas[]" value="<?= $kk; ?>" <?php if($gfasis[$kk]==$kk){echo "checked";} else {}?>>
<label for="<?= $kk; ?>"><?= $fasi[$kk]; ?></label>
</fieldset>
<?php } ?>
i got error like this
maybe someone can help me ?
i just need got check when value same like my database
my database data like this
simple answer
replace this line
<?php if($gfasis[$kk]==$kk){echo "checked";} else {}?>
with this code
<?php if (in_array($kk, $gfasis)){ echo "checked";}?>
so your code will be like this
for($kk=1; $kk<=11; $kk++) { ?>
<fieldset>
<input type="checkbox" id="<?= $kk; ?>" name="fasilitas[]" value="<?= $kk; ?>"
<?php if (in_array($kk, $gfasis)) {echo "checked";} else {}?>>
<label for="<?= $kk; ?>"><?= $fasi[$kk]; ?></label>
</fieldset>
<?php } ?>

get value of radio button using jQuery and php

I want to get the value clicked in radio button.
This is my code:
<ul class="collapsible popout" data-collapsible="accordion" id="clicks">
<?php
foreach ($preguntas['preguntas'] as $row)
{
$opciones = $pregunta->opciones($row[0]);
?>
<li>
<div class="collapsible-header"><i class="material-icons">question_answer</i><?php echo utf8_encode($row[2]); ?></div>
<div class="collapsible-body">
<?php foreach ($opciones as $opcion){ ?>
<p class="left-align" id="options">
<input class="with-gap" name="pregunta_<?php echo utf8_encode($row[0]); ?>" type="radio" id="opcion_<?php echo utf8_encode($opcion[0]); ?><?php echo $row[0] ?>" value="<?php echo $opcion[0]; ?>" />
<label for="opcion_<?php echo $opcion[0]; ?><?php echo utf8_encode($row[0]); ?>"><?php echo utf8_encode($opcion[2]); ?></label>
</p>
<?php } ?>
</div>
<?php } ?>
</li>
</ul>
I need to get the value of this input id="opcion_..."
<p class="left-align" id="options">
<input class="with-gap" name="pregunta_<?php echo utf8_encode($row[0]); ?>" type="radio" id="opcion_<?php echo utf8_encode($opcion[0]); ?><?php echo $row[0] ?>" value="<?php echo $opcion[0]; ?>" />
<label for="opcion_<?php echo $opcion[0]; ?><?php echo utf8_encode($row[0]); ?>"><?php echo utf8_encode($opcion[2]); ?></label>
</p>
The problem is name and id is changing, it's not the same
Any idea?
Thank you.
JQuery selector for part of attribute $("[attribute^='value']") like this:
$("[id^='opcion_']").click(function(){
alert($(this).val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<label><input name="pregunta_xxx" type="radio" id="opcion_123" value="123">radio for 123</label>
<label><input name="pregunta_xxx" type="radio" id="opcion_456" value="456">radio for 456</label>

PHP form with radio buttons - make only one answer required, second optional

I have this PHP form with radio buttons:
{
$agreements = jm_get_application_setting( 'application_agreements', '' );
if( empty( $agreements ) ) return;
$questions = explode( "\n", $agreements );
if (!empty($questions)):
foreach ($questions as $index => $question) :
?>
<div class="form-group">
<p><strong for="question-<?php echo sanitize_title($question); ?>" ><?php echo $question; ?></strong></p>
<div class="form-control-flat">
<label class="radio">
<input type="radio" name="_noo_application_answer_<?php echo $index; ?>" value="1" required><i></i><?php echo esc_html__('Do il consenso', 'noo'); ?>
</label>
</div>
<div class="form-control-flat">
<label class="radio">
<input type="radio" name="_noo_application_answer_<?php echo $index; ?>" value="0" required><i></i><?php echo esc_html__('Nego il consenso', 'noo'); ?>
</label>
</div>
<input type="hidden" name="_noo_questions[]" value="<?php echo esc_attr($question); ?>"/>
</div>
<?php
endforeach;
endif;
}
How can I make only one answer required to validate the form?
I mean.. Just the first MUST be selected, but I also need to show the second one for "legal reasons".
As is, this form accepts both choices as acceptable.
You can set a variable for the condition, and change it's value at the end of first iteration.
if (!empty($questions)):
$first = 1; // <----- HERE
foreach ($questions as $index => $question) :
?>
<div class="form-group">
<p><strong for="question-<?php echo sanitize_title($question); ?>" ><?php echo $question; ?></strong></p>
<div class="form-control-flat">
<label class="radio">
<input type="radio"
name="_noo_application_answer_<?php echo $index; ?>"
value="1"
<?php echo $first ? "required" : ""; ?>> // <----- HERE
<i></i><?php echo esc_html__('Do il consenso', 'noo'); ?>
</label>
</div>
<div class="form-control-flat">
<label class="radio">
<input type="radio"
name="_noo_application_answer_<?php echo $index; ?>"
value="0"
<?php echo $first ? "required" : ""; ?>> // <----- HERE
<i></i><?php echo esc_html__('Nego il consenso', 'noo'); ?>
</label>
</div>
<input type="hidden" name="_noo_questions[]" value="<?php echo esc_attr($question); ?>"/>
</div>
<?php
$first = 0; // <----- HERE
endforeach;
endif;

Writing this PHP code in OO [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I have a PHP function which I want to convert from procedural into OOP but I am confused on how to do it. Please help.
Below is my original PHP code.
function smw_admin() {
global $smw, $shortname, $options;
$i=0;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$smw.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$smw.' settings reset.</strong></p></div>';
?>
<div class="wrap rm_wrap">
<h2><?php echo $smw; ?></h2>
</div>
<form method="post">
<div class="wrap rm_wrap">
<div class="rm_opts">
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<?php break;
case "close":
?>
</div>
</div>
<br />
<?php break;
case "title":
?>
<p>To easily use the <?php echo $smw;?>, you can use the menu below.</p>
<?php break;
case 'text':
?>
<div class="rm_input rm_text">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?>" />
<small><?php echo $value['desc']; ?></small>
<div class="clearfix"></div>
</div>
<?php
break;
case 'textarea':
?>
<div class="rm_input rm_textarea">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?>
</textarea>
<small><?php echo $value['desc']; ?></small>
<div class="clearfix"></div>
</div>
<?php
break;
case 'select':
?>
<div class="rm_input rm_select">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
<option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option>
<?php } ?>
</select>
<small><?php echo $value['desc']; ?></small>
<div class="clearfix"></div>
</div>
<?php
break;
case "checkbox":
?>
<div class="rm_input rm_checkbox">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
<small><?php echo $value['desc']; ?></small>
<div class="clearfix"></div>
</div>
<?php break;
case "section":
$i++;
?>
<div class="rm_section">
<div class="rm_title">
<h3><img src="<?php echo plugin_dir_url(__FILE__);?>/assets/images/trans.png" class="inactive" alt="""><?php echo $value['name']; ?></h3>
<span class="submit">
<input name="save<?php echo $i; ?>" type="submit" value="Save changes" />
</span>
<div class="clearfix"></div>
</div>
<div class="rm_options">
<?php break;
}
}
?>
<input type="hidden" name="action" value="save" />
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
</div>
<?php
}
Here is OOP I wrote,
class Admin_Option{
public function smw_admin() {
$i=0;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$this->smw.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$this->smw.' settings reset.</strong></p></div>';
?>
<div class="wrap rm_wrap">
<h2><?php echo $this->smw; ?></h2>
</div>
<form method="post">
<div class="wrap rm_wrap">
<div class="rm_opts">
<?php foreach ($this->options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<?php break;
case "close":
?>
</div>
</div>
<br />
<?php break;
case "title":
?>
<p>To easily use the <?php echo $this->smw;?>, you can use the menu below.</p>
<?php break;
case 'text':
?>
<div class="rm_input rm_text">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?>" />
<small><?php echo $value['desc']; ?></small>
<div class="clearfix"></div>
</div>
<?php
break;
case 'textarea':
?>
<div class="rm_input rm_textarea">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
<small><?php echo $value['desc']; ?></small>
<div class="clearfix"></div>
</div>
<?php
break;
case 'select':
?>
<div class="rm_input rm_select">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
<option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option>
<?php } ?>
</select>
<small><?php echo $value['desc']; ?></small>
<div class="clearfix"></div>
</div>
<?php
break;
case "checkbox":
?>
<div class="rm_input rm_checkbox">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
<small><?php echo $value['desc']; ?></small>
<div class="clearfix"></div>
</div>
<?php break;
case "section":
$i++;
?>
<div class="rm_section">
<div class="rm_title">
<h3><img src="<?php echo plugin_dir_url(__FILE__);?>/assets/images/trans.png" class="inactive" alt="" /><?php echo $value['name']; ?></h3>
<span class="submit">
<input name="save<?php echo $i; ?>" type="submit" value="Save changes" />
</span>
<div class="clearfix"></div>
</div>
<div class="rm_options">
<?php break;
}
}
?>
<input type="hidden" name="action" value="save" />
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
</div>
<?php
}
}
Does it make sense? Am I going in the right way? Is there any other good way to do it?
Thanks
Before you consider of moving that code to another paradigm (OO) you must first clean it up, so that it can show its true colors, what it does, what it does good (work) and what it does wrong (bugs).
So we must first refactor the code. For example:
Get rid of bugs:
you open <div>s outside of the foreach loop and close them inside the loop and only in case "close". Now since that behavior is controlled by the data structure of $options probably you are feeding the loop with a 'close' value at the end of the data structure and thus that possible error never manifests, but it can and the whole thing makes your code hard to read. Move the closing of the <div>s outside the loop where they must be since we must always close them regardless of the data structure.
Get rid of stale code:
Now the above change results in the 'close' case doing nothing, and you have another case that was doing nothing the 'open' case. Those two cases must be removed altogether - they serve no purpose other than reminding us that somewhere we have a data structure that can have an open and close value.
Gather your inputs:
See what your inputs are and move them to the start of the code blocks so that you can see them in a glance. Give them meaningful names, for example $i probably is counting section numbers so name it $sectionNumber. Also you see now in a specific point that you use an asset according to __FILE__, later when you move the code file to another relative location you will change it easily.
Also in the department of stale code you also have an unused variable, $shortname. We are dropping it also.
Divide the logic from the presentation:
No I don't hint at anything like MVC just get the presentation that is more than one lines out of the way so that you can see the logic of your code. Just make them into functions - even if are going to be used only from one point in the code - and move them out of the way. Later when you have cleaned out the logic you will probably make a proper template that you will feed with the data it needs etc.
see what changes and what remains the same etc
Now all of the above result in the following which is way easier to read:
<?php
function smw_admin() {
global $smw, $options;
$saved = $_REQUEST['saved'];
$reset = $_REQUEST['reset'];
$imageTrans = plugin_dir_url(__FILE__) . '/assets/images/trans.png';
$sectionNumber=0;
if ($saved) echo '<div id="message" class="updated fade"><p><strong>'.$smw.' settings saved.</strong></p></div>';
if ($reset) echo '<div id="message" class="updated fade"><p><strong>'.$smw.' settings reset.</strong></p></div>';
?>
<div class="wrap rm_wrap">
<h2><?php echo $smw; ?></h2>
</div>
<form method="post">
<div class="wrap rm_wrap">
<div class="rm_opts">
<?php
foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
break;
case "close":
break;
case "title":
echo "<p>To easily use the $smw, you can use the menu below.</p>";
break;
case 'text':
render_div_rm_input_rm_text($value);
break;
case 'textarea':
render_rm_input_rm_textarea($value);
break;
case 'select':
render_rm_input_rm_select($value);
break;
case "checkbox":
render_rm_input_rm_checkbox($value);
break;
case "section":
$sectionNumber++;
render_rm_section($imageTrans, $value, $sectionNumber);
break;
}
}
?>
</div>
</div>
<br />
<input type="hidden" name="action" value="save" />
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
</div>
<?php
}
and various functions like:
function render_rm_section($imageTrans, $value, $i)
{
?>
<div class="rm_section">
<div class="rm_title">
<h3><img src="<?php echo $imageTrans; ?>" class="inactive" alt="""><?php echo $value['name']; ?></h3>
<span class="submit">
<input name="save<?php echo $i; ?>" type="submit" value="Save changes"/>
</span>
<div class="clearfix"></div>
</div>
<div class="rm_options">
<?php
}
at that point you could start the OO way - although you should refactor it more for example by not echoing the result directly but instead getting the result as a return value, consolidating more the code base etc.
A 1st phase example could be:
Class SmwPage {
private options;
private $smw;
private $imageTrans;
function __construct($options, $smw) {
$this->options = $options;
$this->smw = $smw;
$this->imageTrans = plugin_dir_url(__FILE__) . '/assets/images/trans.png';
}
function render() {
// render the beggining
// the same code as before only we now operate with $this-> at the class member variables (properties)
foreach ($this->options as $value) {
// switch statement here
}
// render the end
}
with a usage of:
$smwPage = new SmwPage($options, $smw);
$smwPage->render();
Of course the above class would need to change
every time you would need to add a new option and
every time we need to change how an option is rendered
so in the next step you will want to change the data structure to a collection of objects that each knows how to render() itself. Then the render of SmwPage would be only a loop through the collection of those objects and a call to their render() method.

PHP Form Not Displaying With jQuery Mobile

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.

Categories