I have this code, which is very long, sorry.
<ul id="org" style="display:none">
<?php foreach ($note1 as $item1) { ?>
<li>
<?php echo $item1->Node_Id; ?>
<?php foreach ($noteLevel1 as $item2) { ?>
<p style="font-size:15px;padding:10px 5px 10px 0px"><?php echo $item2->LabelNote; ?></p>
<div class="SmallBox" id="<?php echo $item2->DetailNode_id; ?>" style="margin-bottom:10px;">
<input type="text" value="<?php if(empty($item2->Realisasi)) { echo ''; }else{ echo number_format($item2->Realisasi,0,",","."); } ?>" class="TextInput" />
<input type="text" value="<?php if(empty($item2->Target)) { echo ''; }else{ echo number_format($item2->Target,0,",","."); } ?>" class="TextInput" />
<input type="text" value="<?php if(!empty($item2->PercentRealisasi)) { echo $item2->PercentRealisasi.'%'; }else{ echo '0%'; } ?>" class="PercentInput" />
<img class="circles4" src='http://localhost/CST/public/img/green.png' onload="this.onload=null; this.src=GetStatusImage(<?php echo $item2->PercentRealisasi; ?>);" />
</div >
<?php } ?>
<div class="clearDiv"></div>
<?php foreach ($note2 as $item3) { ?>
<?php echo $item3->Node_Id.'T'.$item3->ParentNode; ?>
<ul>
<?php foreach ($noteLevel2 as $item4) { ?>
<li>
<p class="NodeLabel"><?php echo $item4->LabelNote; ?></p>
<div id="<?php echo $item4->DetailNode_id; ?>" class="SmallBox">
<center>
<input type="text" value="<?php if(empty($item4->Realisasi)) { echo ''; }else{ echo number_format($item4->Realisasi,0,",",".");} ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(empty($item4->Target)) { echo ''; }else{ echo number_format($item4->Target,0,",","."); } ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(!empty($item4->PercentRealisasi)) { echo $item4->PercentRealisasi.'%'; }else{ echo '0%'; } ?>" class="PercentInput" readonly="true"/>
<img class="circles" src='http://localhost/CST/public/img/green.png' onload="this.onload=null; this.src=GetStatusImage(<?php echo $item4->PercentRealisasi; ?>);" />
</center>
</div>
<?php foreach ($note3 as $item5) { ?>
<?php echo $item5->Node_Id.'T'.$item5->ParentNode; ?>
<ul>
<?php foreach ($noteLevel3 as $item6) { ?>
<li>
<p class="NodeLabel"><?php echo $item6->LabelNote; ?></p>
<div id="<?php echo $item6->DetailNode_id; ?>" class="SmallBox">
<center>
<input type="text" value="<?php if(empty($item6->Realisasi)) { echo ''; }else{ echo number_format($item6->Realisasi,0,",",".");} ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(empty($item6->Target)) { echo ''; }else{ echo number_format($item6->Target,0,",","."); } ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(!empty($item6->PercentRealisasi)) { echo $item6->PercentRealisasi.'%'; }else{ echo '0%'; } ?>" class="PercentInput" readonly="true"/>
<img class="circles" src='http://localhost/CST/public/img/green.png' onload="this.onload=null; this.src=GetStatusImage(<?php echo $item6->PercentRealisasi; ?>);" />
</center>
</div>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
You can see the table in this picture:
The result should be like this:
I want node_id to appear when node_id is equal with parent_node. But when I try to add code like this:
<?php foreach ($note3 as $item5) { ?>
**<?php if($item5->ParentNode == $item3->Node_Id){ ?>**
<?php echo $item5->Node_Id.'T'.$item5->ParentNode; ?>
<ul>
<?php foreach ($noteLevel3 as $item6) { ?>
<li>
<p class="NodeLabel"><?php echo $item6->LabelNote; ?></p>
<div id="<?php echo $item6->DetailNode_id; ?>" class="SmallBox">
<center>
<input type="text" value="<?php if(empty($item6->Realisasi)) { echo ''; }else{ echo number_format($item6->Realisasi,0,",",".");} ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(empty($item6->Target)) { echo ''; }else{ echo number_format($item6->Target,0,",","."); } ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(!empty($item6->PercentRealisasi)) { echo $item6->PercentRealisasi.'%'; }else{ echo '0%'; } ?>" class="PercentInput" readonly="true"/>
<img class="circles" src='http://localhost/CST/public/img/green.png' onload="this.onload=null; this.src=GetStatusImage(<?php echo $item6->PercentRealisasi; ?>);" />
</center>
</div>
</li>
<?php } ?>
</ul>
<?php } ?>
<?php } ?>
And the result should be like this:
It's like I just loop with the first index of the array. How can I fix it?
Related
I'm doing a php assignment which asks of us to make a quiz, which has 1 question per page, and cycles through five different questions picked at random through a next and previous button. My friend and I have been able to direct the code to go to other pages, but for some reason, the changing of question from 1 to the next does not work.
This is what we did in the body section of our work.
<body>
<div class="nav">
<ul>
<li><i class="fa fa-question-circle" aria-hidden="true"></i></i> Quiz
</li>
<li><i class="fa fa-list" aria-hidden="true"></i> Leaderboard</li>
<li><i class="fa fa-window-close" aria-hidden="true"> Exit</i></li>
</ul>
</div>
<br /><br />
<?php
$fp = fopen("questions.txt", "r");
$rowdata = "";
if ($fp) {
while (($buffer = fgets($fp, 10240)) !== false) {
$rowdata .= $buffer;
}
if (!feof($fp)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($fp);
}
$data = json_decode($rowdata);
if(isset($_POST['nickname']) && isset($_POST['topic'])) {
//random
$name = $_POST['nickname'];
$topic = $_POST['topic'];
$randomArray = [];
$counter = 1;
while($counter <= 5)
{
$random_val;
if($_POST['topic'] == "geography"){
$random_val= rand(0,9);
}
else{
$random_val= rand(10,19);
}
if(!in_array($random_val,$randomArray)){
array_push($randomArray,$random_val);
$counter++;
}
}
$selected_question_ids = [];
foreach ($randomArray as $val) {
array_push($selected_question_ids,$data[$val]->id);
}
//random end
if($_POST['topic'] == "geography"){
?>
<section>
<form action="result.php" method="POST">
<ol>
<?php
$q_counter = 1;
foreach($data as $row) {
if(in_array($row->id,$selected_question_ids))
{
?>
<li><?php echo $row->question?></li>
<ol>
<li><input type="radio" name="<?php echo $q_counter?>"
value="<?php echo $row->a?>"><?php echo $row->a?></li>
<li><input type="radio" name="<?php echo $q_counter?>"
value="<?php echo $row->b?>"><?php echo $row->b?></li>
<li><input type="radio" name="<?php echo $q_counter?>"
value="<?php echo $row->c?>"><?php echo $row->c?></li>
<input type="hidden" name="q_id_<?php echo $q_counter?>" value="<?php echo $row->id?>">
</ol>
<?php
$q_counter++;
}
}
?>
<input type="hidden" name="name" value="<?php echo $name ?>">
<input type="hidden" name="topic" value="<?php echo $topic ?>">
</ol>
<input type="button" name="prev" value="Prev" onclick="prev()">
<input type="button" name="next" value="Next" onclick="next()">
<button type="submit">Submit Quiz</button>
</form>
<script>
function next() {
<li><?php echo $row->question?></li>
<ol>
<li><input type="radio" name="<?php echo $q_counter?>"
value="<?php echo $row->a?>"><?php echo $row->a?></li>
<li><input type="radio" name="<?php echo $q_counter?>"
value="<?php echo $row->b?>"><?php echo $row->b?></li>
<li><input type="radio" name="<?php echo $q_counter?>"
value="<?php echo $row->c?>"><?php echo $row->c?></li>
<input type="hidden" name="q_id_<?php echo $q_counter?>" value="<?php echo $row->id?>">
</ol>
<?php
$q_counter++;
?>
}
</script>
</section>
<?php
}
if($_POST['topic'] == "history"){
?>
<section>
<form action="result.php" method="POST">
<ol>
<?php
$q_counter = 1;
foreach($data as $row) {
if(in_array($row->id,$selected_question_ids))
{
?>
<li><?php echo $row->question?></li>
Ans : <input type="text" name="<?php echo $q_counter?>" id="" required>
<input type="hidden" name="q_id_<?php echo $q_counter?>" value="<?php echo $row->id?>">
<br>
<br>
<?php
$q_counter++;
}
}
?>
<input type="hidden" name="name" value="<?php echo $name ?>">
<input type="hidden" name="topic" value="<?php echo $topic ?>">
</ol>
<input type="button" name="prev" value="Prev" onclick="<?php echo $row->question?>">
<input type="button" name="next" value="Next" onclick="<?php echo $row->question?>">
<button type="submit">Submit Quiz</button>
</form>
</section>
<?php
}
}
?>
</body>
And for what we expect, when we start the quiz, after we fill in the first question, we would be able to switch from question 1 to the next question by clicking on the next button, or go back to the previous one with the click of the previous button. Is there any idea how to work this? We are not able to make that function work.
Note: we put while($counter <= 5) as a temporary fix to show all 5 questions at once instead of 1 at a time for the time being. this should be changed to while($counter <= 1) by the end.
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>
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.
Evry time while logging in an error "INVALID TOKEN" its shown at the joomla2.5/jomsocial2.4 site, but after 2,3 refreshes it shows the profile page as logged in... why is it so.... Is it problem of Joomla... I have uninstalled a plugin alphauserpoints ... is that a problem.. or should i modify the code default.php
<?php
// no direct access
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
?>
<?php if ($type == 'logout') : ?>
<form action="<?php echo JRoute::_('index.php', true, $params->get('usesecure')); ?>" method="post" id="login-form">
<?php if ($params->get('greeting')) : ?>
<div class="login-greeting">
<?php if($params->get('name') == 0) : {
echo JText::sprintf('MOD_LOGIN_HINAME', $user->get('name'));
} else : {
echo JText::sprintf('MOD_LOGIN_HINAME', $user->get('username'));
} endif; ?>
</div>
<?php endif; ?>
<div class="logout-button">
<input type="submit" name="Submit" class="button" value="<?php echo JText::_('JLOGOUT'); ?>" />
<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="user.logout" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
<?php else : ?>
<form action="<?php echo JRoute::_('index.php', true, $params->get('usesecure')); ?>" method="post" id="login-form" >
<?php if ($params->get('pretext')): ?>
<div class="pretext">
<p><?php echo $params->get('pretext'); ?></p>
</div>
<?php endif; ?>
<fieldset class="userdata">
<p id="form-login-username">
<label for="modlgn-username"><?php echo JText::_('MOD_LOGIN_VALUE_USERNAME') ?></label>
<input id="modlgn-username" type="text" name="username" class="inputbox" size="18" />
</p>
<p id="form-login-password">
<label for="modlgn-passwd"><?php echo JText::_('JGLOBAL_PASSWORD') ?></label>
<input id="modlgn-passwd" type="password" name="password" class="inputbox" size="18" />
</p>
<?php if (JPluginHelper::isEnabled('system', 'remember')) : ?>
<p id="form-login-remember">
<label for="modlgn-remember"><?php echo JText::_('MOD_LOGIN_REMEMBER_ME') ?></label>
<input id="modlgn-remember" type="checkbox" name="remember" class="inputbox" value="yes"/>
</p>
<?php endif; ?>
<input type="submit" name="Submit" class="button" value="<?php echo JText::_('JLOGIN') ?>" />
<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="user.login" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
<?php echo JHtml::_('form.token'); ?>
</fieldset>
<ul>
<li>
<a href="<?php echo JRoute::_('index.php?option=com_users&view=reset'); ?>">
<?php echo JText::_('MOD_LOGIN_FORGOT_YOUR_PASSWORD'); ?></a>
</li>
<li>
<a href="<?php echo JRoute::_('index.php?option=com_users&view=remind'); ?>">
<?php echo JText::_('MOD_LOGIN_FORGOT_YOUR_USERNAME'); ?></a>
</li>
<?php
$usersConfig = JComponentHelper::getParams('com_users');
if ($usersConfig->get('allowUserRegistration')) : ?>
<li>
<a href="<?php echo JRoute::_('index.php?option=com_users&view=registration'); ?>">
<?php echo JText::_('MOD_LOGIN_REGISTER'); ?></a>
</li>
<?php endif; ?>
</ul>
<?php if ($params->get('posttext')): ?>
<div class="posttext">
<p><?php echo $params->get('posttext'); ?></p>
</div>
<?php endif; ?>
or does the uninstallation affected the configuration file of joomla
Try this link: http://developersbench.in/invalid-token-during-registration-jomsocial/#.T19wtHm45F0 . You might get some help from this.
The info i have about this is every time you open a page and submit a form it first validates the token and if token is expired which is mainly because of remaining idle on the page for a few time, then you get "Invalid token" error.
Simply if you are not worried about the token, go to the file root/libraries/joomla/environment/request.php and check the below function
function checkToken( $method = 'post' ), comment all the lines between this and simply return true, whatever be the case. I haven't tried this, but i guess this will work.
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.