I'm having a problem with my php code, when I try to echo a form inside a php I see it outside of div.
<?php
if ( is_user_logged_in() ) {
echo '<div class="loginformheader" style="margin-top: 0;">
<div id="reg-login">خروج</div></div>';
} else {
echo '<div class="loginformheader">'.header_login_form().'<div id="reg-login">تسجيل<span>|</span><a style="cursor: pointer;" id="logina">دخول</a><i class="fa fa-angle-up"></i></div></div>';
}
?>
The output
<p class="login-username">
<label for="user_login"></label>
<input type="text" name="log" id="user_login" class="input" value="" size="20" placeholder="اسم المستخدم">
</p>
<p class="login-password">
<label for="user_pass"></label>
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" placeholder="كلمة المرور">
</p>
<p class="login-remember"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever"> تذكرني</label></p>
<p class="login-submit">
<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="تسجيل الدخول">
<input type="hidden" name="redirect_to" value="http://localhost:8080/wordpress/2014/10/30/links-post-2/">
</p>
</form><div class="loginformheader"><div id="reg-login">تسجيل<span>|</span><a style="cursor: pointer;" id="logina">دخول</a><i class="fa fa-angle-up"></i></div></div> <hgroup class="site-branding">
<img class="site-logo" src="http://localhost:8080/wordpress/wp-content/themes/merwaa/img/logo.svg">
Maybe my English not very good, sorry me for that.
Can you help me?
Have a look at your header_login_form() function. It almost certainly echos the form, rather than returning it as a string. If that's the case, it'll be echoed when it's evaluated, which will be before the string it's in can be evaluated. Try this instead:
<?php
if ( is_user_logged_in() ) {
echo '<div class="loginformheader" style="margin-top: 0;">
<div id="reg-login">خروج</div></div>';
} else {
echo '<div class="loginformheader">';
header_login_form();
echo '<div id="reg-login">تسجيل<span>|</span><a style="cursor: pointer;" id="logina">دخول</a><i class="fa fa-angle-up"></i></div></div>';
}
?>
Related
I'm facing this strange issue.
I need to upload multiple image with one input. On the input I have a js code that shows me the uploaded image, but when I try to check the $_POST array the image are not submitted.
Half an hour ago it worked well, so I thought it was a cache problem, but even if I empty the cache I cant manage the problem. I cant remember if I changed something, but the code seems to be the same as before (when the code worked).
I work with MAMP on windows 10.
Here is the html (the "form-question" div including the image input is the last one below):
<form action="?mode=dati" method="post" id="dati" enctype="multipart/form-data">
<div class="form-question">
<label for="n2">Nome dell'azienda</label>
<input type="text" id="n2" name="nomeAzienda" value="<?php echo $_SESSION['nomeAzienda']?>">
</div>
<div class="form-question">
<label for="n3">Indirizzo</label>
<input type="text" id="n3" name="indirizzo" value="<?php echo $_SESSION['indirizzo']?>">
</div>
<div class="flex">
<label for="n3">Cap</label>
<input type="text" id="n3" name="cap" value="<?php echo $_SESSION['cap']?>">
<label for="n4">Città</label>
<input type="text" id="n4"name="citta" value="<?php echo $_SESSION['citta']?>">
<label for="n5">Provincia</label>
<input type="text" id="n5" name="provincia" value="<?php echo $_SESSION['provincia']?>">
<label for="n6">P.IVA</label>
<input type="text" id="n6" name="partitaIva" value="<?php echo $_SESSION['partitaIva']?>">
</div>
<div class="form-question">
<label for="n7">Indirizzo email</label>
<input type="text" name="email" id="n7" value="<?php echo $_SESSION['email']?>">
</div>
<div class="form-question">
<label for="immagine">Immagine</label>
<input type="file" name="immagine[]" class="form-control"
oninput="immagine_preview.src=window.URL.createObjectURL(this.files[0]);
immagine_preview1.src=window.URL.createObjectURL(this.files[1]);
immagine_preview2.src=window.URL.createObjectURL(this.files[2]); " multiple/>
<img id="immagine_preview" width="100px" height="100px">
<img id="immagine_preview1" width="100px" height="100px">
<img id="immagine_preview2" width="100px" height="100px">
</div>
<div class="button-wrapper">
<button type="submit" id="registra">Registra i dati</button>
<button type="button" id="prosegui" class="disabled">Prosegui</button>
</div>
</form>
And here is the php:
if ( $_GET ) {
if ( isset( $_GET[ 'id_sondaggio' ] ) || isset( $_GET[ 'mode' ] ) ) {
$id_sondaggio = $_GET[ 'id_sondaggio' ];
$mode = $_GET[ 'mode' ];
}
}
if ( $mode == 'dati' ) {
var_dump($_POST);
die();
}
I'm not getting what's wrong here. Thank you for all your help.
i have two table rooinventory and reservation i want to store values in that tables but its getting inserting in rooinventory table only..
demo.php
<form name="checkoutForm" method="post" action="order.php">
<div class="container" style="float: left; width: 299px; margin-left: 12px;">
<span class="top-label">
<span class="label-txt">Room Details</span>
</span>
<div class="content-area" style="border-radius:15px;">
<div>
</div>
<div class="content drop-here">
<div id="cart-icon">
<img src="img/Shoppingcart_128x128.png" alt="shopping cart" class="pngfix" width="128" height="128" />
<img src="img/ajax_load_2.gif" alt="loading.." id="ajax-loader" width="16" height="16" />
</div>
<input name="start" type="hidden" value="<?php echo $arival; ?>" />
<input name="end" type="hidden" value="<?php echo $departure; ?>" />
<input name="numnights" type="hidden" value=<?php echo $numberofnights; ?>" />
<div>
<div id="item-list">
</div>
<div id="total"></div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<span class="top-label">
<span class="label-txt">Personal Details</span>
</span>
<div class="content-area" style="border-radius:15px; padding-bottom: 25px;">
<div>
Firstname:<br>
<input type="text" name="fname" id="boxy" pattern="[A-Za-z]{1,32}" required="" /><br>
lastname:<br>
<input type="text" name="lname" id="boxy" required="" /><br>
Address:<br>
<input type="text" name="address" id="boxy" pattern="[A-Za-z]{1,32}" required="" /><br>
City:<br>
<input type="text" name="city" id="boxy" required="" /><br>
Country:<br>
<input type="text" name="country" id="boxy" required="" /><br>
Email:<br>
<input type="email" name="email" id="boxy" /><br>
Contact Number:<br>
<input type="text" name="contact" id="boxy" required="" /><br>
<input type="hidden" name="confirmation" id="boxy" value="<?php echo $confirmation ?>" /><br>
<input type="submit" name="check" onclick="document.forms.checkoutForm.submit(); return false;" class="button" value="Checkout" id="boxy" style="width: 147px; margin-top: 18px;">
</div>
</div>
</div>
</form>
order.php
<?php
$confirmation = $_POST['confirmation'];
$numnights=round($_POST['numnights']);
$arival=$_POST['start'];
$departure=$_POST['end'];
$firstname=$_POST['fname'];
$lastname=$_POST['lname'];
$address=$_POST['address'];
$city=$_POST['city'];
$country=$_POST['country'];
$email=$_POST['email'];
$contact=$_POST['contact'];
$stat='active';
$roomid=$_POST['id'];
$qty=$_POST['qty'];
$price=$_POST['price'];
$roomname=$_POST['roomname'];
$N = count($roomid);
$ip_sqlq=mysql_query("select * from rooinventory where confirmation='$confirmation' and arrival='$arival'and departure='$departure'");
$countq=mysql_num_rows($ip_sqlq);
if($countq==0)
{
for($i=0; $i < $N; $i++)
{
mysql_query("INSERT INTO rooinventory (room, qty, arrival, departure, status, confirmation) VALUES ('$roomid[$i]','$qty[$i]','$arival','$departure','$stat','$confirmation')");
echo '<h2>'.$qty[$i].' x '.$roomname[$i].' = '.$ble=$qty[$i]*$price[$i].'</h2>';
echo '<div style="display:none;">';
$dddd=$ble;
$total=$total+$dddd;
echo '</div>';
}
mysql_query("INSERT INTO reservation (firstname, lastname, city, address, country, email, contact, arrival, departure, result, payable, status, confirmation) VALUES ('$firstname','$lastname','$city','$address','$country','$email','$contact','$arival','$departure','$numnights','$total','$stat','$confirmation')");
header("location: paypalpayout.php?confirm=$confirmation");
}
else{
header("location: ../index.php");
}
?>
Could it be the data in one of your variables is causing the second query to fail? Since they're not bound as parameters or at least escaped, they could be altering your actual query. For instance, if there's an apostrophe in any of your data, it's going to break the query.
I have an form with submit button as follows in html :-
<div style="display: flex;">
<form name="myform"method="post" action="usdbtc.php" style="float:left;">
<div id="log_err"> <strong><?php if(isset($logerror)) { echo $logerror; } else { $dn = 'dn'; } ?></strong> </div>
<p><label style="float: left;">Price:</label><input class="input101" style="float: left;" type="text" name="username" id="box1" oninput="calculate()"><label style="float: right;">: BTC</label><input class="input101" style="float: right;" type="text" name="username" id="box2" oninput="calculate()">
<br><input class="input101" style="float: right;" type="text" name="username" id="result"><br><label style="padding: 10px;">Total BTC:</label>
<td rowspan="2">
<input type="hidden" id="myform" value="1"/>
<br><span class="orderbutton" type="submit" id="ordersell" onclick="myform.submit()">SELL</span></p>
</td>
</form>
<form name="yourform"method="post" action="usdbtc.php" style="float:right;">
<p><label style="float: left;">Price:</label><input class="input101" style="float: left;" type="text" name="username" id="box3" oninput="calculate()"><label style="float: right;">: BTC</label><input class="input101" style="float: right;" type="text" name="username" id="box4" oninput="calculate()">
<br><input class="input101" style="float: right;" type="text" name="username" id="resul"><br><label style="padding: 10px;">Total BTC:</label>
<td rowspan="2">
<input type="hidden" id="yourform" value="1"/>
<br>
<span class="orderbutton" type="submit" id="orderbuy" onclick="yourform.submit()">BUY</span></p>
</td>
</form>
</div>
And to check whether user clicked 'SELL' button i do in php :-
if($_POST['myform']){
echo 'yes';
}
else {
echo 'no';
}
I am always getting no after clicking button, is there anything wrong that I haved coded in the html or php part? Help is appreciated.. I just want to get the part for php
if($_POST['?']) {...
Remember there are two forms in the page with each having name and hidden input id.
<input type="hidden" id="myform" value="1"/>
Change id attribute to name
<input type="hidden" name="myform" value="1">
And there's a missing space in form tag
I have a popup which shows up if the user is not logged in. It contains a cancel link, a form to enter details, and a forget password link. My problem is when the user comes back from the forget password link and clicks the cancel link, it takes them back to the forget password page.
Here is my code.
<div class="contactForm_new" id="popUpDiv" style="display:none;">
<!--<div class="lightBlue heading" >Tell us your Buy Requirement</div>-->
<div class="blueLightBG heading" style="text-align: left;
padding-left: 2%;background-color:#009bcb ">Enter Password <span class=" dpbl fr mainSp cr_bt2 p_a closeTrigger closePopup href" style="position: absolute; display: block;"></span></div>
<form method="post" class="contactF" id="login-form">
<input type="hidden" value="" name="offerid">
<input type="hidden" value="" name="refvalue">
<input type="hidden" value="" name="tenderid">
<input type="hidden" value="" name="item_id">
<input type="hidden" value="" name="pid">
<input type="hidden" value="sd" name="ref">
<input type="hidden" value="1" name="isLogRequest">
<input type="hidden" name="iso" id="iso" value="<?php echo $details['iso'] ?>">
<input type="hidden" value="<?php echo $return_en_url ?>" id="p_address" name="p_address">
<div class="errorMessage" id="errorUsername"></div>
<input type="hidden" name="diff_usr" value="Y">
<input type="hidden" value="Y" name="diff_usr">
<input class="pd3 textlogin_new" name="LoginForm[password]" id="LoginForm_password" type="password">
<div class="errorMessage" id="errorPassword"></div>
<div style="padding:15px 0;text-align:center">
<span id="imgprcp" class="fl" style=" display: none; text-align: center;margin-left:50%;"><img src="<?php echo Yii::app()->params['hostName'] ?>/images/ind.gif" alt="Proceeding"></span>
<input id="btnSubmit" type="button" name="yt0" value="Proceed" class="redBtn_new" >
</div>
<div class="mb3per" style="display:block">
<p class="k7_new" style="position:absolute;" >
<a class="k7_new" id="forgotpass" style="position:relative;" href="<?php echo Yii::app()->params['hostName'] ?>/forgotpass/?ref=<?php echo $ref ?>&p=<?php echo $return_en_url ?>" >Forgot Password?</a>
</p>
</div>
</form>
</div>
Can anybody suggest what am I doing wrong? All of my URLs are formed correctly.This problem is coming in only chrome browser.In another browser it is working fine
I have been struggling to put a content locker to a form in my template and I succeeded but form is fetching some php values so my echo has PHP code in it. Not sure how do I do it.
Can anyone help? I am struggling since 10 hours and couldn't come to a solution.
<?
$locker='[ihc-hide-content ihc_mb_type="block" ihc_mb_who="all" ihc_mb_template="1"]
<form id="contact" type="post" action="" >
<span class="contact-name">
<input type="text" name="contactName" id="contactName" value="" class="input-textarea" placeholder="<?php _e("Name*", "themesdojo"); ?>" />
</span>
<span class="contact-email">
<input type="text" name="email" id="email" value="" class="input-textarea" placeholder="<?php _e("Email*", "themesdojo"); ?>" />
</span>
<span class="contact-message">
<textarea name="message" id="message" cols="8" rows="8" ></textarea>
</span>
<span class="contact-test">
<p style="margin-top: 20px;"><?php _e("Human test. Please input the result of 5+3=?", "themesdojo"); ?></p>
<input type="text" onfocus="if(this.value=='')this.value='';" onblur="if(this.value=='')this.value='';" name="answer" id="humanTest" value="" class="input-textarea" />
</span>
<input type="text" name="receiverEmail" id="receiverEmail" value="<?php echo $wpjobus_job_email; ?>" class="input-textarea" style="display: none;"/>
<input type="hidden" name="action" value="wpjobContactForm" />
<?php wp_nonce_field( 'scf_html', 'scf_nonce' ); ?>
<input style="margin-bottom: 0;" name="submit" type="submit" value="<?php _e( 'Send Message', 'themesdojo' ); ?>" class="input-submit">
<span class="submit-loading"><i class="fa fa-refresh fa-spin"></i></span>
</form>
[/ihc-hide-content]';
echo do_shortcode( $locker );
?>
just concat your php variables
$locker='[ihc-hide-content ihc_mb_type="block" ihc_mb_who="all" ihc_mb_template="1"]
<form id="contact" type="post" action="" >
<span class="contact-name">
<input type="text" name="contactName" id="contactName" value="" class="input-textarea" placeholder="'._e("Name*", "themesdojo").'" />
</span>
<span class="contact-email">
<input type="text" name="email" id="email" value="" class="input-textarea" placeholder="'._e("Email*", "themesdojo").'" />
</span>
<span class="contact-message">
<textarea name="message" id="message" cols="8" rows="8" ></textarea>
</span>
<span class="contact-test">
<p style="margin-top: 20px;">'._e("Human test. Please input the result of 5+3=?", "themesdojo").'</p>
<input type="text" onfocus="if(this.value=="")this.value="";" onblur="if(this.value=="")this.value="";" name="answer" id="humanTest" value="" class="input-textarea" />
</span>
<input type="text" name="receiverEmail" id="receiverEmail" value="'.$wpjobus_job_email.'" class="input-textarea" style="display: none;"/>
<input type="hidden" name="action" value="wpjobContactForm" />
'.wp_nonce_field( 'scf_html', 'scf_nonce' ).'
<input style="margin-bottom: 0;" name="submit" type="submit" value="'._e( 'Send Message', 'themesdojo' ).'" class="input-submit">
<span class="submit-loading"><i class="fa fa-refresh fa-spin"></i></span>
</form> [/ihc-hide-content]';
echo do_shortcode( $locker );
Line 25 contains PHP that is being interpreted as part of the $locker variable.
<?php wp_nonce_field( 'scf_html', 'scf_nonce' ); ?>