PHP htmlentities() messes up output? - php

This is a voting plugin for Wordpress, but I think the problem is PHP, so I posted it here.
3 fields allow the user to paste HTML code (Voting up, Voting down, and HTML displayed after voting):
value="<?php echo htmlentities(get_option('voteiu_sinktext')); ?>"
value="<?php echo htmlentities(get_option('voteiu_votetext')); ?>"
value="<?php echo htmlentities(get_option('voteiu_aftervotetext')); ?>"
I added an <img> tag to the first two fields. And they are displayed correctly but when I add an image to the last one voteiu_aftervotetext (<img src="http://localhost/taiwantalk/wp-content/plugins/vote-it-up/voting-disabled.png" />) . The first two fields (Vote Up and Vote Down) output like this:
<a voting-disabled.png"="" vote-it-up="" plugins="" wp-content="" taiwantalk=""
localhost="" http:="" href="javascript:vote('votecount47','voteid47','<img
src=">',47,1,'http://localhost/taiwantalk/wp-content/plugins/vote-it-up');"><img
src="http://localhost/taiwantalk/wp-content/plugins/vote-it-up/uparrow.png"></a>
config file:
<?php
/* VoteItUp configuration page */
function VoteItUp_options() {
if (function_exists('add_options_page')) {
add_options_page("Vote It Up", "Vote It Up", 8, "voteitupconfig", "VoteItUp_optionspage");
add_options_page("Edit Votes", "Edit Votes", 8, "voteitupeditvotes", "VoteItUp_editvotespage");
}
}
/* Wordpress MU fix, options whitelist */
if(function_exists('wpmu_create_blog')) {
add_filter('whitelist_options','voteitup_alter_whitelist_options');
function voteitup_alter_whitelist_options($whitelist) {
if(is_array($whitelist)) {
$option_array = array('voteitup' => array('voteiu_initialoffset','voteiu_votetext','voteiu_sinktext','voteiu_aftervotetext','voteiu_allowguests','voteiu_allowownvote','voteiu_limit','voteiu_widgetcount','voteiu_skin'));
$whitelist = array_merge($whitelist,$option_array);
}
return $whitelist;
}
}
//Page meant for administrators
function VoteItUp_optionspage() {
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div>
<h2><?php _e('Voting options'); ?></h2>
<form method="post" action="options.php">
<?php
/* bugfix for wordpress mu */
if(function_exists('wpmu_create_blog')) {
wp_nonce_field('voteitup-options');
echo '<input type="hidden" name="option_page" value="voteitup" />';
} else {
wp_nonce_field('update-options');
}
?>
<h3>General</h3>
<table class="form-table" border="0">
<tr valign="top">
<th scope="row" style="text-align: left;">Initial vote count</th>
<td>
<input type="text" name="voteiu_initialoffset" id="voteiu_initialoffset" value="<?php if (get_option('voteiu_initialoffset')=='') { echo '0'; } else { echo get_option('voteiu_initialoffset'); } ?>" />
</td></tr>
<tr valign="top">
<th scope="row" style="text-align: left;">Name of positive votes</th>
<td>
<input type="text" name="voteiu_votetext" id="voteiu_votetext" value="<?php echo htmlentities(get_option('voteiu_votetext')); ?>" /><br />
You can use <code><img></code> to use images instead of text. Example: <code><img src="<?php echo VoteItUp_ExtPath(); ?>/uparrow.png" /></code><br />
Default: <code>Vote</code>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: left;">Name of negative votes</th>
<td>
<input type="text" name="voteiu_sinktext" id="voteiu_sinktext" value="<?php echo htmlentities(get_option('voteiu_sinktext')); ?>" <?php if (!GetCurrentSkinInfo('supporttwoway')) { echo 'disabled="disabled" '; }?>/><br />
<?php if (GetCurrentSkinInfo('supporttwoway')) { ?>You can use <code><img></code> to use images instead of text. Example: <code><img src="<?php echo VoteItUp_ExtPath(); ?>/downarrow.png" /></code><br />
If this is left blank two-way voting is disabled.<?php } else {
?>Current widget template does not support two-way voting<?php } ?>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: left;">Text displayed after vote is cast</th>
<td>
<input type="text" name="voteiu_aftervotetext" id="voteiu_aftervotetext" value="<?php echo htmlentities(get_option('voteiu_aftervotetext')); ?>" /><br />
You can use <code><img></code> to use images instead of text. Text is displayed after user casts a vote. If this is left blank the vote button disappears.
</td>
</tr>
</table>
<h3>Permissions</h3>
<table class="form-table" border="0">
<tr valign="top">
<th scope="row" style="text-align: left;">Allow guests to vote</th>
<td>
<input type="checkbox" name="voteiu_allowguests" id="voteiu_allowguests" value="true" <?php if (get_option('voteiu_allowguests') == 'true') { echo ' checked="checked"'; } ?> />
</td></tr>
<tr valign="top">
<th scope="row" style="text-align: left;">Post author can vote own post</th>
<td>
<input type="checkbox" name="voteiu_allowownvote" id="voteiu_allowownvote" value="true" <?php if (get_option('voteiu_allowownvote') == 'true') { echo ' checked="checked"'; } ?> />
</td></tr>
</table>
<h3>Theming</h3>
<p>External templates for the voting widgets can be installed via the "skin" directory. Voting widgets using <code><?php DisplayVotes(get_the_ID()); ?></code> will use the new themes. Setting this to "none" will result in the default bar theme being used.</p>
<?php SkinsConfig(); ?>
<h3>Widget</h3>
<p>The widget shows posts which have the most votes. Only new posts are considered to keep the list fresh.</p>
<p>The widget can be displayed to where you want by using the following code: <code><?php MostVotedAllTime(); ?></code>, or if your template supports widgets it can be added via the widgets panel.</p>
<table class="form-table" border="0">
<tr valign="top">
<th scope="row" style="text-align: left;">No. of most recent posts to be considered</th>
<td><input type="text" name="voteiu_limit" id="voteiu_limit" value="<?php echo get_option('voteiu_limit'); ?>" /><br />
Default: <code>100</code>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: left;">No. of posts shown in widget</th>
<td><input type="text" name="voteiu_widgetcount" id="voteiu_widgetcount" value="<?php if (get_option('voteiu_widgetcount')=='') { echo '10'; } else {echo get_option('voteiu_widgetcount');} ?>" /><br />
Default: <code>10</code>
</td>
</tr>
</table>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="voteiu_initialoffset,voteiu_votetext,voteiu_sinktext,voteiu_aftervotetext,voteiu_allowguests,voteiu_allowownvote,voteiu_limit,voteiu_widgetcount,voteiu_skin" />
<h3>Voting code</h3>
<p>The following code should be added in your index.php and single.php. This displays the vote buttons.</p>
<p><strong>Themable Version</strong><br />
<code><?php DisplayVotes(get_the_ID()); ?></code></p>
<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" />
</p>
</form>
</div>
<?php
}
the file which controls the output:
<span class="barcontainer"><span class="barfill" id="votecount<?php echo $postID ?>" style="width:<?php echo round($barvotes[0] * 2.5); ?>%;"> </span></span>
<?php if ($user_ID != '') {
if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { ?>
<span>
<?php if(!UserVoted($postID,$user_ID)) { ?><span class="bartext" id="voteid<?php the_ID(); ?>">
<?php echo get_option('voteiu_votetext'); ?><?php if (get_option('voteiu_sinktext') != '') { ?><?php echo get_option('voteiu_sinktext'); ?>
<?php } ?>
</span>
<?php } else { ?>
<?php if (get_option('voteiu_aftervotetext') != '') { ?><span class="bartext" id="voteid<?php the_ID(); ?>"><?php echo get_option('voteiu_aftervotetext'); ?></span><?php } ?>
<?php } ?>
</span>
<?php } } else {
if (get_option('voteiu_allowguests') == 'true') { ?>
<span>
<?php if(!GuestVoted($postID,md5($_SERVER['REMOTE_ADDR']))) { ?><span class="bartext" id="voteid<?php the_ID(); ?>">
<?php echo get_option('voteiu_votetext'); ?><?php if (get_option('voteiu_sinktext') != '') { ?><?php echo get_option('voteiu_sinktext'); ?>
<?php } ?>
</span>
<?php } ?>
</span>
Is like the third field inserts itself in the anchor tag of the first two.
Is the problem spot-able with the information provided above?

Related

set two different type checkbox color in the form using php codeigniter

<table class="table table-hover">
<tr>
<th>Sl.No</th>
<th> All </th>
<th>Regno.</th>
<th>Name</th>
<!--<?php echo "Core Subjects" ?> -->
<?php
foreach($getsubc as $rowc)
{
?>
<td align="center">
<?php echo $rowc['subcode']; ?>
<input type="checkbox" id="check-all" onClick="toggle(this,<?php echo $rowc['markid']; ?>)" value="<?php echo $rowc['markid']; ?>" checked="checked" data-checkbox-class="icheckbox_square-green">
</td>
</div>
<?php
}
?>
<!-- Elective subjects -->
<?php
foreach($getsube as $rowe)
{
?>
<td align="center">
<?php echo $rowe['subcode']; ?>
<input type="checkbox" id="check-all2" onClick="toggle(this,<?php echo $rowe['markid']; ?>)" value="<?php echo $rowe['markid']; ?>" data-checkbox-class="icheckbox_square-blue">
</td>
<?php
}?>
</tr>
<?php
$sno=1;
foreach($getstud as $row)
{
echo '<tr>'; ?>
<?php
echo '<td>'.$sno++.'</td>';
echo '<td><input type="checkbox" value="' . $row['regno'] . '" name="regno[]"></td>';
echo '<td>'.$row['regno'].'</td>';
echo '<td>'.$row['name'].'</td>';
?>
<?php ?>
<?php foreach($getsubc as $row1)
{?>
<td align="center"> <input type="checkbox" data-checkbox-class="icheckbox_square-green" name="friend_id[]"
value="<?php echo $row1['markid'];?>" >
</td>
</td>
</div>
</td>
</div>
</div>
<?php
} ?>
<?php
foreach($getsube as $row2)
{
?>
<td align="center"> <input type="checkbox" data-checkbox-class="icheckbox_square-blue" name="friend_id[]" value="<?php echo $row2['markid']; ?>" /> </td>
<?php
}
echo '</tr>';
}
?>
</table>
<script src="<?= base_url('assets/plugins/iCheck/icheck.min.js') ?>"></script>
$('input:checkbox').iCheck({
increaseArea: '25%' // optional
});
</script>
<script language="JavaScript">
function toggle(source, markid) {
checkboxes = document.getElementsByName(markid);
for(var i=0, n=checkboxes.length;i<n;i++) {
checkboxes[i].checked = source.checked;
}
}
</script>
i changes the code accordingly your solution . but not working both color and select_all method . whats wrong with this code
i changes the code accordingly your solution . but not working both color and select_all method . whats wrong with this code
i changes the code accordingly your solution . but not working both color and select_all method . whats wrong with this code
First, change your iCheck initialization to this:
$('input:checkbox').iCheck({
increaseArea: '25%' // optional
});
Then do this on first set:
<td align="center">
<?php echo $row1['subcode']; ?>
<input type="checkbox" id="check-all" onClick="toggle(this,<?php echo $row1['markid']; ?>)" value="<?php echo $row1['markid']; ?>" checked="checked" data-checkbox-class="icheckbox_square-green">
</td>
And then on your second set:
<td align="center">
<?php echo $row2['subcode']; ?>
<input type="checkbox" id="check-all2" onClick="toggle(this,<?php echo $row2['markid']; ?>)" value="<?php echo $row2['markid']; ?>" data-checkbox-class="icheckbox_square-blue">
</td>
Notice the use of data-checkbox-class attribute on each of the input:checkbox tags. Which you can apply the same on the ones within data tables.

Show only relevant search results

I have created a page for search, and I'm having some problems.
The data is displayed on the page but I also use some fields on the form for a specific field, so when I enter the data in those fields and hit search, it shows the search field on the top of the display page with the rest of the data, but I want only the data which belongs to my search.
CODE:
<?php
include('connect.php');
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include('include/head.php')?>
</head>
<body>
<div id="header-wrapper">
<div id="header">
<div id="menu">
<ul>
<?php include('include/menu.php') ?>
Logout
</ul>
</div>
</div>
</div>
<div id="logo">
<?php include('include/logo.php'); ?>
</div>
<div id="wrapper">
<div id="page">
<div id="page-bgtop">
<div id="content">
<div class="post">
<div class="entry-image">
<?php
$q=mysql_query("SELECT count( php ) AS ph, count( dotnet ) AS dot, count( design ) AS des FROM candidate");
while($row=mysql_fetch_array($q))
{
?>
<form name="" method="post">
<table border="1" cellpadding="10" cellspacing="1" width="280" height="200">
<th colspan="5" bgcolor="orange" >Total Number of Resume by skills</th>
<tr>
<th><B>PHP</B></th>
<th><B>DOTNET</B></th>
<th><B>DESIGN</B></th>
</tr>
<td><?php echo "$row[ph]"; ?></td>
<td><?php echo "$row[dot]"; ?></td>
<td><?php echo "$row[des]"; ?></td>
</table>
</form>
<?php
}
?>
</div>
<h2 class="title">Welcome to Resume </h2>
<div class="entry">
<p>
<form name="search" method="post" action="searchview.php">
<table>
<tr>
Id: <input type="text" name="id" /></br></br>
Name:<input type="text" name="name" /><br/></br>
Expected Salary:<input type="text" name="es" /><br/></br>
Skill Rate: <input type="text" name="sr" /><br/> </br>
Salary:<input type="text" name="cs" /></br></br>
<input type="submit" name="submit" value="seach" /><input type="reset" name="reset" value="reset" />
</tr>
</table>
</form>
</p>
</div>
</div>
<div class="post" >
<?php
$query=mysql_query("select * from candidate");
while($row=mysql_fetch_array($query))
{
$sno=$row['id'];
$image=$row['image'];
$name=$row['fname'];
$es=$row['es'];
$sr=$row['sr'];
$cs=$row['cs'];
?>
<form name="view" method="post" action="searchview.php" >
<table border="1" cellpadding="30" class="centered" width="20" >
<tr>
<th width="150">S.NO</th>
<th width="150">IMAGE</th>
<th width="150">NAME</th>
<th width="150">EXPECTED SALARY</th>
<th width="150">SKILL RATE</th>
<th width="150">SALARY</th>
<th width="150">ACTION</th>
</tr>
<td><?php echo "$row[id]"; ?></td>
<td><div class="rightdiv1a"><img src="<?php echo 'img/'.$row['image']; ?>" style="height:120px; width:145px; "></div></td>
<td><?php echo "$row[fname]"; ?></td>
<td><?php echo "$row[es]"; ?></td>
<td><?php echo "$row[sr]"; ?></td>
<td><?php echo "$row[cs]"; ?></td>
<td><img alt='view' title='view' src='images/view.png' width='15px' height='15px' hspace='20' /></td>
<td><img alt='Edit' title='Edit' src='images/edit.png' width='15px' height='15px' hspace='20' /></td>
<td><a onclick="return confirm('Would you like to delete?');" href="delete.php?id=<?php echo "$row[id]"; ?>"><img alt='delete' title='delete' src='images/delete.png' width='15px' height='15px' hspace='20' /></a></td>
</table>
</form>
<?php
}?>
</div>
</div>
</div>
</div>
</div>
<div id="footer-bgcontent">
<div id="footer">
<?php// include('include/footer.php');?>
</div>
</div>
</body>
</html>
<?php// } ?>
This code displays the data now but I want to filter the data and only show the results which belongs to my search, and have the rest disappear.
Here are some screenshots of my form:
pls help,
thanks in advance..
If I understand the question correctly, you want to display the search results, but no longer show the search form. If this is the case, then move your second "post" div to the top and wrap it in an if:
if (!empty($_POST)) {
// Process POST results here:
...
die(); // end processing so the form doesn't display again
}

Parse error: syntax error, unexpected 'else' (T_ELSE) in php

Hey guys I m having a tricky issue but unable to get out of it.
Here I m providing a radio button with namely two option free or paid registration but when I going in else part I m receiving an error.
I checked out the syntax line by line still it is unable to resolve why I m getting and error for else.
Please check and help me out.
<?php $regtype = (isset($postdata['regtype']))? $postdata['regtype']:0;?>
Registration Type: <?php echo $form->radio("regtype",array('0' => $translate->_("Free"),'1' =>$translate->_("Paid")),array('separator'=>"\n",'value'=>$regtype));?>
<?php $type = $_POST['data[regtype]'];?>
<?php if ($type == "Free")
?>
<form action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="POST">
<?php if($agency['monthly_fee'] != ''):?>
<?php echo $form->hidden("monthly_fee",array('value'=>$agency['monthly_fee']));?>
<?php endif;?>
<table class="list" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="200">Plan</th>
<td>
<?php $a="Monthly Rs.600"; $b="3 months Rs. 1,650"; $c="12 months Rs. 6,000"; ?>
<?php echo $form->select("plan",array($a=>'Monthly Rs.600',$b=>'3 months Rs. 1,650',$c=>'12 months Rs. 6,000'),$postdata["plan"]);?>
</td>
</tr>
<tr>
<th width="200"><?php echo $translate->_("student_master_name");?></th>
<td>
<?php echo $translate->_("student_master_name1");?>:<?php echo $form->text("name1",array('value'=>$postdata["name1"]));?>
<?php echo $translate->_("student_master_name2");?>:<?php echo $form->text("name2",array('value'=>$postdata["name2"]));?>
</td>
</tr>
<?php if($gl_locale=="ja"):?>
<tr>
<th>ローマ字</th>
<td>
Surnames:<?php echo $form->text("roma1",array('value'=>$postdata["roma1"]));?>
Given names:<?php echo $form->text("roma2",array('value'=>$postdata["roma2"]));?>
</td>
</tr>
<?php endif;?>
<tr>
<th scope="row"><?php echo $translate->_("student_master_gender");?></th>
<td>
<?php $gender = (isset($postdata['gender']))? $postdata['gender']:0;?>
<?php echo $form->radio("gender",array('0' => $translate->_("common_male"),'1' =>$translate->_("common_female")),array('separator'=>"\n",'value'=>$gender));?>
</td>
</tr>
<tr>
<th scope="row"><?php echo $translate->_("student_master_birth");?></th>
<td>
<?php echo $form->year("birth",1900,date("Y"),$postdata['birth_year'],array('name'=>'data[birth_year]'),"----"); ?><?php echo $translate->_("common_year");?>
<?php echo $form->month("birth",$postdata['birth_month'],array('name'=>'data[birth_month]'),"--");?><?php echo $translate->_("common_month");?>
<?php echo $form->day("birth",$postdata['birth_day'],array('name'=>'data[birth_day]'),"--");?><?php echo $translate->_("common_day");?>
</td>
</tr>
<tr>
<th><?php echo $translate->_("student_master_country");?></th>
<td>
<?php echo $form->select("country_id",$country_data,$postdata['country_id'],array('id'=>'country'),$translate->_("common_choose"));?>
</td>
</tr>
<tr>
<th><?php echo $translate->_("student_master_email");?></th>
<td><?php echo $form->text("email",array('id'=>'mail','value'=>$postdata['email'])); ?></td>
</tr>
<tr>
<th width="200"><?php echo $translate->_("student_master_login_id");?></th>
<td><?php echo $form->text("login_id",array('class'=>'required ||','value'=>$postdata['login_id']));?> <?php echo $translate->_("bmat-entry-tdtxt");?></td>
</tr>
<tr>
<th><?php echo $translate->_("student_master_login_password");?></th>
<td><?php echo $form->password("login_password",array('class'=>'required ||','value'=>$postdata['login_password']));?></td>
</tr>
<tr>
<th><?php echo $translate->_("student_master_login_password");?>(<?php echo $translate->_("bmat-entry-thtxt");?>)</th>
<td><?php echo $form->password("login_password_cfm",array('class'=>'required ||','value'=>$postdata['login_password_cfm']));?></td>
</tr>
</table>
<?php if(!isset($postdata['c-code'])) $postdata['c-code'] = $coupon_code;?>
<?php echo $form->hidden("c-code",array('class'=>'||','value'=>$postdata['c-code']));?>
<?php echo $form->hidden('MemberInfoToken',array('value'=>$MemberInfoToken))?>
<?php echo $form->hidden('stat',array('value'=>'confirm'))?>
<?php //echo $form->hidden('entry_date',array('value'=>date('Y/m/d')))?>
<?php if($gl_locale == 'ja'):?>
<h3><?php echo $translate->_("bmat-entry-kiyaku");?></h3>
<div id="agreement" class="mrg-t10">
<p class="mrg-t10" style="font-weight:bold;">第1条(本規約の適用)</p>
<p>1. 本規約はイープランニング(以下当社という)が運営する特定ドメイン上のウェブサイト 「B-MAT」(以下当社ウェブサイトという)において提供する教育プログラムサービス(以下本サービスという)を、利用者 (第2条にて定義します)が利用する場合の遵守すべき諸条件を定めるものです。</p>
<p>2. 当社は、本サービスの各々について適宜、個別の利用規約(以下「個別規 約」といいます)を定めることができるものとします。</p>
<p style="font-weight:bold;">第2条(ご利用条件について)</p>
<p>利用者には、当社が当該利用者の利用登録を承認した時点で、当社が提供する本サー ビスを利用する資格(以下、「利用者資格」といいます)が与えられます。<br />
利用者は、本利用規約の他、当社が定める各種の規約(以下、「個別規程」といいます)に同意頂き、本サービ スをご利用ください。 なお、本利用規約と個別規程の定めが異なる場合には、個別規程の定めが優先するものとします。<br />
本利用規約および個別規程(以下、併せて「本利用規約等」といいます)については、利用者に対する事前の通 知なく、当社が変更できるものとします。 本利用規約等が変更された場合、当該変更後の利用者による本サービスの利用に は変更後の本利用規約等が適用されるものとし、当該利用により、利用者は当該変更に同意したものとみなされます。</p>
<p style="font-weight:bold;">第3条(著作権について)</p>
<p>本Webサイトに掲載されている著作物(文書、資料、画像、音声、動画等)の著作権は、 イープランニングまたはその他の権利者に帰属します。 これらの著作物につきましては、別段の定めがある場合を除き、私的 使用その他著作権法で特に認められている範囲を超えてご利用(複製、改変、上映、公衆送信、頒布、再使用許諾等を含 む)はできません。 仮に、営利目的でご使用になった場合、相応の使用料をいただくか、使用差し止めの処置を取る場合もあ りますのでご注意ください。</p>
<p style="font-weight:bold;">第4条(利用上の注意)</p>
<p>利用者は、利用に際して登録した情報(以下、「登録情報」といいます。メールアドレス やパスワード等を含みます)について、自己の責任の下、任意に登録、管理するものとします。 利用者は、第三者にパスワ ードを使用されることのないよう、以下の事項を守らなければなりません。</p>
<p>・第三者に自己のパスワードを公開しないこと。<br />
・複数の人間が使用するコンピュータならびに携帯電話上で本サービスを利用する場合は、本 サービスの利用を終えるときに必ずログアウトしウェブブラウザを終了させること。<br />
・複数の人間が使用するコンピュータ上で本サービスを利用する場合は、ログイン情報記録(ログイン時のメールアド レスとパスワードの入力を省略できる機能)の登録解除を行っておくこと。<br />
・当社は、登録されたパスワードによって本サービスの利用があった場合、利用登録をおこな った本人が利用したものと扱うことができ、当該利用によって生じた結果ならびにそれに伴う一切の責任については、利用登録 を行った本人に帰属するものとします。<br />
登録情報の管理は、利用者が自己の責任の下で行うものとし、登録情報が不正確または虚偽であったために利用 者が被った一切の不利益および損害に関して、当社は責任を負わないものとします。</p>
<p style="font-weight:bold;">第5条(個人情報について)</p>
<p>個人情報は、当社が別途定めるプライバシーポリシーに則り、適正に取り扱うこととしま す。 <br />
利用者の同意なく、機密保持契約を結んだ協力企業以外に利用者の個人情報を開示することはありません。ただ し、以下の場合に、個人情報を開示することがあります。</p>
<p>・法令に基づいて、開示が必要であると当社が合理的に判断した場合<br />
・人の生命、身体または財産の保護のために必要がある場合であって、本人の同意を得るこ とが困難であると判断した場合<br />
・公衆衛生の向上または児童の健全な育成の推進のために特に必要がある場合であって、本 人の同意を得ることが困難であると判断した場合<br />
・国の機関もしくは地方公共団体またはその委託を受けた者が法令の定める事務を遂行するこ とに対して協力する必要がある場合であって、本人の同意を得ることにより当該事務の遂行に支障を及ぼすおそれがあると判断 した場合<br />
・合併その他の事由によりサービスの主体が変更され、サービスの継続のため個人情報を移管する必要があると判断した場合</p>
<p>ワールドカップおよびワールドカップJrに入賞した場合は、名前と国名のみ当サイトのワールドカップサイト内に表示します。</p>
<p style="font-weight:bold;">第6条(免責)</p>
<p>・何らかの原因によるシステム障害が起こった場合、その時の獲得ポイントや賞品が無効となる場合があります。<br />
・ポイント獲得および商品交換など、諸所のルールが途中で変更になる場合があります。 </p>
</div><!--agreement-->
<div id="agree-chk">
<input type="hidden" name="data[agree]" value="0">
<label><input name="data[agree]" type="checkbox" value="1"> <?php echo $translate->_("bmat-entry-doui");?></label>
</div>
<?php else:?>
<input type="hidden" name="data[agree]" value="1">
<?php endif;?>
<div style="text-align:center" class="mrg-t10">
<input type="button" name="back" value=" <?php echo $translate->_("otn_member_entry_index_back");?> " onclick="history.back();"/>
<input type="submit" name="btnSubmit" value=" <?php echo $translate->_("otn_member_entry_index_confirm");?> " />
</div>
<?php endif;?>
</form>
<?php else:?> **<!-- Here I m getting an error -->**
<label>In paid registration</label>
<?php endif;?>
Looks like you might have an extra end if:
<?php else:?>
<input type="hidden" name="data[agree]" value="1">
<?php endif;?>
<div style="text-align:center" class="mrg-t10">
<input type="button" name="back" value=" <?php echo $translate->_("otn_member_entry_index_back");?> " onclick="history.back();"/>
<input type="submit" name="btnSubmit" value=" <?php echo $translate->_("otn_member_entry_index_confirm");?> " />
</div>
<?php endif;?>

form php submission gives same style

I'm creating a page with a PHP form, and it works well. But the problem is when I hit the checl button check it gives answers in the white page, not in the same html tabl.
I want it to gives the submission in the same table style , as well as add a new button to the form that shows answers without taking the exercise.
And this is an example, showing want I'm trying to do:
http://www.englisch-hilfen.de/en/exercises/questions/simple_present.htm
<?php
$correctSolution1 = 'do';
$correctSolution2 = 'do';
if(isset($_POST['add']) == TRUE) {
$solution1 = $_POST['solution1'];
if(empty($solution1) == TRUE) {
echo '<span style="color: blue;">"unanswered"</span> you like lemon?</br>';
} else if ($solution1 == $correctSolution1) {
echo '<span style="color: green;">'.$solution1.'</span> you like lemon?</br>';
} else {
echo '<span style="color: red;">'.$solution1.'</span> you like lemon?</br>';
}
$solution2 = $_POST['solution2'];
if ( empty($solution2) == TRUE ) {
echo '<span style="color: blue;">"_____"</span> you like lemon? <img src="http://www.pavendors.com/images/smileyface.gif" width="16px" height="16px" border=0></br>';
} else if ( $solution2 == $correctSolution2 ) {
echo '<span style="color: green;">'.$solution2.'</span> you like lemon?</br>';
} else {
echo '<span style="color: red;">'.$solution2.'</span> you like lemon?</br>';
}
echo '<input type="button" value="Repeat test" />';
} else {
?>
<form method="post" autocomplete="off">
<table align=center width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table align=left width="100%" bgcolor="#FFCC99" border="0" cellspacing="0" cellpadding="1">
<tr>
<td>
<table width="100%" bgcolor="#FFFFCC" cellspacing="4" cellpadding="1">
<tr></tr>
<tr><td></td></tr>
<tr>
<td>
<table> <tr><td colspan="2">1) <input type="text" name="solution1" value="" size="6" /> you <input type="text" class="ex_textfield" id="1" tabindex="1" name="solution2" value="" size="6" /> mineral water? <b><i>(to drink)</i></b></td></tr>
</table>
</td>
</tr>
<tr><td height="1"><hr></td></tr>
<tr>
<td align="left"><input class="small_button" type="submit" name="add" value="Check" />
<br>
<hr> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php
}
?>
You should look in to embeeding php inside html:
In example above you are doing :
<?php
$correctSolution1 = 'do';
$correctSolution2 = 'do';
if(isset($_POST['add']) == TRUE) {
}
else{?>
<form>
<table></table>
</form>
<?php }?>
So you code here does not go to form and table part when you do a submit(post request) through from.
You can either add table part to the post if statement part as well like below:
<?php
$correctSolution1 = 'do';
$correctSolution2 = 'do';
if(isset($_POST['add']) == TRUE) {
//do your php stuffs here
?>
<table>
...
your html you can include values in to it like this <?php echo $solution2;?>
...
</table>
<?php
}
else{?>
<form>
<table></table>
</form>
<?php }?>
OR you can do this as well:
<?php
//php part here may be some variable assignments
$correctSolution1 = 'do';
correctSolution2 = 'do';
?>
<form>
<table>
....
<?php if(isset($_POST['add']) == TRUE) {?>
your other code here for result
<?php }?>
....
</table>
</form>
So basically you will need to understand properly about embedding php in to html.
You may look in to alternative syntax in php for statements like if, while, for, switch;
http://php.net/manual/en/control-structures.alternative-syntax.php
you can do things like:
<?php if(true):?>
//if code here
<?php endif;?>

ajax post in search

I make search form and I'm using it as ajax searchform.
I have problems in html(data), when I put the html(data) it will display the loading image and the table too it will double here's my code:
$(document).ready(function(){
$("#loading").hide();
<?php $type_temp = (!empty($type)) ? 'company/' .$type:'company';?>
$("#search_id").click(function(){
$("#loading").show();
$.post("<?php echo url_for('/AdmSys_dev.php/' .$type_temp); ?>", $("#send_search").serialize(), function(data){
$(".result").html(data);
});
});
});
How will I put the result into the page?
heres my html code below
<div id="sf_admin_content">
<h2>Company</h2><br />
<div style="margin-bottom:20px;">
<form id="send_search" action="" method="get">
<input type="text" name="search" placeholder="Search: " value="<?php echo $search; ?>" />
<input id="search_id" type="button" value="Search" />
</form>
</div>
Add
<div id="loading" style="margin-left:186px; margin-top:30px;">
<img alt="" src="/images/preloader_transparent.gif" />
</div>
<table class="location" cellspacing="0" style="width:500px;">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Description</th>
<th>Photo</th>
<th>Option</th>
</tr>
</thead>
<tbody class="result">
<?php foreach($company as $x => $companies): ?>
<tr id="company<?php echo $companies->getId(); ?>" class="<?php echo ($x&1) ? 'even':'odd'; ?>">
<td align="right"><?php echo $companies->getId(); ?></td>
<td><?php echo $companies->getName(); ?></td>
<td><?php echo $companies->getDescription(); ?></td>
<td><img alt="" src="/uploads/company/<?php echo $companies->getImageFull(); ?>" /></td>
<td align="right">
<a href="<?php echo url_for('company/edit?id=' .$companies->getId() )?>">
<img alt="edit" src="/images/pencil.png" />
</a>
<a href="#delete" title="delete" onclick="return goDelete(<?php echo $companies->getId(); ?>)">
<img alt="delete" src="/images/delete.png" />
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
$type_temp = (!empty($type))?'company/'.$type:'company';
$data = array(
'maxPerPage' => $company->getmaxPerPage(),
'lastPage' => $company->getlastPage(),
'nbResults' => $company->getnbResults(),
'curPage' => $curPage,
'linkPage' => '/AdmSys.php/company'.$type_temp. '?search'.$search
);
include_partial('event/pager',$data); ?>
</div>
as youve notice i put the class results in the <tbody class="result></tbody>

Categories