I have proxy server powered on PHProxy 0.5b2 where is included mini url form. But there is an problem with CSS. Every visited page overwrite and overlap my own CSS.
I tried to add own style="" for every object but is not working (visited sites overwrite css).
My index.inc.php
if ($_flags['include_form'] && !isset($_GET['nf']))
{
$_url_form = '<div style="width:100%;margin:0;text-align:center;border-bottom:1px solid #725554;color:#000000;background-color:#F2FDF3;font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans,arial,sans-serif;padding:4px;">'
. '<form method="post" action="' . $_script_url . '">'
. ' <label for="____' . $_config['url_var_name'] . '">Address:</label> <input id="____' . $_config['url_var_name'] . '" type="text" size="80" name="' . $_config['url_var_name'] . '" value="' . $_url . '" />'
. ' <input type="submit" name="go" value="Go" />'
. ' [go: up one dir, main page]'
. '<br /><hr />';
foreach ($_flags as $flag_name => $flag_value)
{
if (!$_frozen_flags[$flag_name])
{
$_url_form .= '<label><input type="checkbox" name="' . $_config['flags_var_name'] . '[' . $flag_name . ']"' . ($flag_value ? ' checked="checked"' : '') . ' /> ' . $_labels[$flag_name][0] . '</label> ';
}
}
$_url_form .= '</form></div>';
$_response_body = preg_replace('#\<\s*body(.*?)\>#si', "$0\n$_url_form" , $_response_body, 1);
}
Any help?
Thanks
Peter
Related
I want to add a class 'checked' to the <span class="label product-option"> when a radio button is checked and remove when a other radio is checked.
How can I extend my code for this?
$htmlValue = $_value->getOptionTypeId();
if ($arraySign) {
$checked = (is_array($configValue) && in_array($htmlValue, $configValue)) ? 'checked' : '';
} else {
$checked = $configValue == $htmlValue ? 'checked' : '';
}
$spanClass = "input-radio";
if ($checked) {
$spanClass = "input-radio checked";
}
$selectHtml .= '<li>' . '<span class="input-radio"><input type="' . $type . '" class="' . $class . ' ' . $require
. ' product-custom-option"'
. ($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"')
. ($this->helper('core')->currencyByStore($_value->getPrice(true), $store, false) ? '0' : ' checked="checked"')
. ' name="options[' . $_option->getId() . ']' . $arraySign . '" id="options_' . $_option->getId()
. '_' . $count . '" value="' . $htmlValue . '" ' . $checked . ' price="'
. $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false) . '" /></span>'
. '<span class="label product-option' . $spanClass . '"><label for="options_' . $_option->getId() . '_' . $count . '"><span class="option-name">'
. $this->escapeHtml($_value->getTitle()) . '</span>' . $priceStr . '</label></span>';
if ($_option->getIsRequire()) {
$selectHtml .= '<script type="text/javascript">' . '$(\'options_' . $_option->getId() . '_'
. $count . '\').advaiceContainer = \'options-' . $_option->getId() . '-container\';'
. '$(\'options_' . $_option->getId() . '_' . $count
. '\').callbackFunction = \'validateOptionsCallback\';' . '</script>';
}
$selectHtml .= '</li>';
Your code shows that you already know how to tell if an element is checked or not, and how to set variables containing class names.
Just extend that logic.
$spanClass = "input-radio";
if ($checked) {
$spanClass = "input-radio checked";
}
...
'<span class="' . $spanClass . '">'
I didn't bother to check you php-code to find out how the html would look like exactly (maybe use Streams next time?), but you need to register an eventhandler like this:
(using jQuery as you seem to already be using it anyways)
$('.input-radio input[type=radio]').change(function() {
// $('.input-radio.checked').removeClass('checked'); // this works if you only have one .input-radio
/* if you want multiple (with different names) */
// note: template string are only available in ES6, if you use earlier versions, use the + to concatinate strings
$(`.input-radio.checked input[type=radio][name=${this.name}]`)
.parents('.input-radio.checked').removeClass('checked');
$(this).parents('.input-radio').addClass('checked');
});
/* This CSS is NOT needed and is only used for effect */
.wrapper span {
display: block;
/* To make them vertically aligned, usually makes no sense for span I know */
}
span.input-radio.checked {
background-color: yellow;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<span class="input-radio checked">
<label>
Radio Button
<input type="radio" name="myRadio" checked/>
</label>
</span>
<span class="input-radio">
<label>
Radio Button
<input type="radio" name="myRadio"/>
</label>
</span>
<span class="input-radio">
<label>
Radio Button
<input type="radio" name="myRadio"/>
</label>
</span>
<span class="input-radio">
<label>
Radio Button
<input type="radio" name="myRadio"/>
</label>
</span>
<span class="input-radio">
<label>
Radio Button
<input type="radio" name="myRadio"/>
</label>
</span>
<span class="input-radio">
<label>
Radio Button
<input type="radio" name="myRadio"/>
</label>
</span>
</div>
As a side note, personally I prefer using data-attributes for things like this instead of classes as that more clearly separates design from function.
This question already has answers here:
The 3 different equals
(5 answers)
Closed 5 years ago.
querying is my problem to choose the correct answer .
.
.
.
please answer my problem
*
<?php
$sql = "SELECT * FROM questions_exam_tbl WHERE exam_id = '" . $_POST['subject'] . "'";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
if($row['test_num'] = $qnumber){
echo '
<h3>' . $row['test_num']. '. ' . $row['test_question'] . '</h1>
<input type="radio" name="choiceA" value="' . $row['choice_A'] . '"> ' . $row['choice_A'] . '
<input type="radio" name="choiceA" value="' . $row['choice_B'] . '"> ' . $row['choice_B'] . '
<input type="radio" name="choiceA" value="' . $row['choice_C'] . '"> ' . $row['choice_C'] . '
<input type="radio" name="choiceA" value="' . $row['choice_D'] . '"> ' . $row['choice_D'] . '
';
}
}
?>
*
if($row['test_num'] = $qnumber)
should be
if($row['test_num'] == $qnumber)
Single = is for value assigning. For comparison it is == or ===.
Fetching questions from database and displaying in screen now what should be the logical part or how to implement for checking if selected answer is correct or not and how to store correct answer in database and verifying them.
Here is the code
<?php
// Create connection
$conn = new mysqli("localhost","root","","QuizQuestions");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully<br><br>";
$sql = "SELECT Question, Answer1, Answer2, Answer3, Answer4 FROM Questions";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$i = 1;
while ($row = $result->fetch_assoc()) {
echo "<br>Question: " . $row["Question"] . "<br>";
echo ' A) <input type="radio" name="ans' . $i . '" value="' .
$row["Answer1"] . '">' . $row["Answer1"] . '<br>';
echo ' B) <input type="radio" name="ans' . $i . '" value="' .
$row["Answer2"] . '">' . $row["Answer2"] . '<br>';
echo ' C) <input type="radio" name="ans' . $i . '" value="' .
$row["Answer3"] . '">' . $row["Answer3"] . '<br>';
echo ' D) <input type="radio" name="ans' . $i . '" value="' .
$row["Answer4"] . '">' . $row["Answer4"] . '<br>';
$i++;
}
} else {
echo "0 results";
}
$conn->close();
?>
Because all of the radio inputs have the same name. They all will be considered as same radio group. You need to have different names for different questions. Something like -
$i = 1;
while ($row = $result->fetch_assoc()) {
echo "<br>Question: " . $row["Question"] . "<br>";
echo ' A) <input type="radio" name="ans' . $i . '" value="' . $row["Answer1"] . '">' . $row["Answer1"] . '<br>';
echo ' B) <input type="radio" name="ans' . $i . '" value="' . $row["Answer2"] . '">' . $row["Answer2"] . '<br>';
echo ' C) <input type="radio" name="ans' . $i . '" value="' . $row["Answer3"] . '">' . $row["Answer3"] . '<br>';
echo ' D) <input type="radio" name="ans' . $i . '" value="' . $row["Answer4"] . '">' . $row["Answer4"] . '<br>';
$i++;
}
You also can use the row id instead of the of $i.
You have set same name for all radio buttons. You should group the radio buttons for each question. For that you can get the question id from the database and set the radio button name like
echo ' A) <input type="radio" name="ans'.$row["id"].'"
value="'.$row["Answer1"].'">'.$row["Answer1"].'<br>';
Make sure you have different names for each input field in the radio group so that it treats each question as a different record.
I know there are a lot of topics on this, and I've looked at them all, and they don't help me. My table name is correct, no spaces or anything out of the ordinary. I've checked 100 times and checked 100 more. I'll post both bits of my code, and hopefully someone can help.
I get this error when I try to use the submit button:
Error updating odds: Unknown column 'homeOdds' in 'field list'
POST:
if ($_POST['action'] == 'Update') {
foreach($_POST['game'] as $game) {
$homeScore = ((strlen($game['homeScore']) > 0) ? $game['homeScore'] : 'NULL');
$homeOdds = (str_replace("\xBD", ".5", $homeScore));
$visitorScore = ((strlen($game['visitorScore']) > 0) ? $game['visitorScore'] : 'NULL');
$visitorOdds = (str_replace("\xBD", ".5", $visitorScore));
$sql = "update " . $db_prefix . "schedule ";
$sql .= "set homeOdds = '" . $homeOdds . "', visitorOdds = '" . $visitorOdds . "' ";
$sql .= "where gameID = " . $game['gameID'];
mysql_query($sql) or die('Error updating odds: ' . mysql_error());
}
header('Location: index.php');
}
Table/Form & Update button:
<form id="scoresForm" name="scoresForm" action="odds.php" method="post">
<input type="hidden" name="week" value="<?php echo $week; ?>" />
<?php
$sql = "select s.*, ht.city, ht.team, ht.displayName, vt.city, vt.team, vt.displayName ";
$sql .= "from " . $db_prefix . "schedule s ";
$sql .= "inner join " . $db_prefix . "teams ht on s.homeID = ht.teamID ";
$sql .= "inner join " . $db_prefix . "teams vt on s.visitorID = vt.teamID ";
$sql .= "where weekNum = " . $week . " ";
$sql .= "order by gameTimeEastern";
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
echo '<table cellpadding="4" cellspacing="0" class="table1">' . "\n";
echo ' <tr><th colspan="6" align="left">Week ' . $week . '</th></tr>' . "\n";
$i = 0;
while ($result = mysql_fetch_array($query)) {
$homeTeam = new team($result['homeID']);
$visitorTeam = new team($result['visitorID']);
$rowclass = (($i % 2 == 0) ? ' class="altrow"' : '');
echo ' <tr' . $rowclass . '>' . "\n";
echo ' <td><input type="hidden" name="game[' . $result['gameID'] . '][gameID]" value="' . $result['gameID'] . '" />' . date('D n/j g:i a', strtotime($result['gameTimeEastern'])) . ' ET</td>' . "\n";
echo ' <td align="right"><input type="hidden" name="gameID[' . strtolower($visitorTeam->team) . ']" value="' . $result['gameID'] . '" />' . $visitorTeam->teamName . '</td>' . "\n";
echo ' <td><input type="text" name="game[' . $result['gameID'] . '][visitorScore]" id="game[' . $result['gameID'] . '][visitorScore]" value="' . $result['visitorOdds'] . '" size="3" /></td>' . "\n";
echo ' <td align="right"><input type="hidden" name="gameID[' . strtolower($homeTeam->team) . ']" value="' . $result['gameID'] . '" />at ' . $homeTeam->teamName . '</td>' . "\n";
echo ' <td><input type="text" name="game[' . $result['gameID'] . '][homeScore]" id="game[' . $result['gameID'] . '][homeScore]" value="' . $result['homeOdds'] . '" size="3" /></td>' . "\n";
echo ' </tr>' . "\n";
$i++;
}
echo '</table>' . "\n";
}
?>
<br><input type="submit" name="action" value="Update" />
</form>
Any help is appreciated.
For debugging this, echo (or var_dump) the dynamically generated SQL contained in the $sql variable, before you submit it to the database.
Then take that statement to another client to test it.
MySQL is telling you that the table schedule which you are referencing doesn't contain a column named homeOdds.
We don't see the contents of all the variables that are being incorporated into the SQL text. (The code appears to be vulnerable to SQL Injection.
I am using Wordpress and phpBB with a plugin called wp-united. I am trying to have users redirected back to the homepage of my blog instead of the forum. I have tried making changes but have not been successful so I removed my changes.
Here is the current code:
get_currentuserinfo();
$loggedIn = $phpbbForum->user_logged_in();
$loginLang = ($loggedIn) ? sprintf($phpbbForum->lang['LOGOUT_USER'], $phpbbForum->get_username()) : $phpbbForum->lang['LOGIN'];
$loginAction = ($loggedIn) ? '?mode=logout' : '?mode=login';
if($loggedIn) {
$wpu_usr = get_wpu_phpbb_username();
$colour = $phpbbForum->get_userdata('user_colour');
$colour = ($colour) ? ' style="color: #' . $colour . '" ' : '';
$ret .= _wpu_add_class($before, 'wpu-widget-lu-avatar') . '<img src="' . get_avatar_reader() . '" alt="' . $phpbbForum->lang['USER_AVATAR'] . '" />' . $after;
$ret .= _wpu_add_class($before, 'wpu-widget-lu-username'). '<a href="' . $phpbbForum->get_board_url() . 'ucp.' . $phpEx . '" ' . $colour . '><strong>' . $wpu_usr . '</strong></a>' . $after;
if ( $showRankBlock ) {
$ret .= _wpu_add_class($before, 'wpu-widget-lu-rankblock') . get_wpu_phpbb_rankblock() . $after;
}
$ret .= _wpu_add_class($before, 'wpu-logout') . '' . $loginLang . '' . $after;
} else {
if ( $showLoginForm ) {
$redir = wpu_get_redirect_link();
$login_link = $phpbbForum->append_sid('ucp.'.$phpEx.'?mode=login') . '&redirect=' . $redir;
$ret .= '<form class="wpuloginform" method="post" action="' . $phpbbForum->get_board_url() . $login_link . '">';
$ret .= $before . '<label for="phpbb_username">' . $phpbbForum->lang['USERNAME'] . '</label> <input tabindex="1" class="inputbox autowidth" type="text" name="username" id="phpbb_username"/>' . $after;
$ret .= $before . '<label for="phpbb_password">' . $phpbbForum->lang['PASSWORD'] . '</label> <input tabindex="2" class="inputbox autowidth" type="password" name="password" id="phpbb_password" maxlength="32" />' . $after;
if ( $autoLogin ) {
$ret .= $before . '<input tabindex="3" type="checkbox" id="phpbb_autologin" name="autologin" /><label for="phpbb_autologin"> ' . __('Remember me', 'wp-united') . '</label>' . $after;
}
$ret .= $before . '<input type="submit" name="login" class="wpuloginsubmit" value="' . __('Login') . '" />' . $after;
$ret .= $before . '' . __('Register', 'wp-united') . '' . $after;
$ret .= $before . '' . __('Forgot Password?', 'wp-united') . '' . $after;
$ret .= '</form>';
} else {
$ret .= $before . '' . $loginLang . '';
}
}
/**
* Returns a URL suitable for sending as a redirect instruction to phpBB
* # since v0.8.1
*/
function wpu_get_redirect_link() {
global $phpbbForum;
if(!empty( $_SERVER['REQUEST_URI'])) {
$protocol = empty($_SERVER['HTTPS']) ? 'http:' : ((strtolower($_SERVER["HTTPS"]) == 'on') ? 'https:' : 'http:');
$protocol = ($_SERVER['SERVER_PORT'] == '80') ? $protocol : $protocol . $_SERVER['SERVER_PORT'];
$link = $protocol . '//' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
} else {
$link = get_option('home');
}
$fStateChanged = $phpbbForum->foreground();
$link = reapply_sid($link);
$phpbbForum->restore_state($fStateChanged);
return urlencode(esc_attr($link));
}