How to assign array value to textarea in smarty php - php

I have form where i have to edit this information. I can fetch all the fields to edit except description. Why textarea is not accepting dynamic array value? this is my issue.Please help me to fix this. Thanks in advance!!.
<form id="commentForm" name="commentForm" action="index.php?mdf=addbiography" method="POST" enctype="multipart/form-data" >
{if $admindetails[0].name neq ''}
<input type="hidden" id="action" name="action" value="saveupdate">
<input type="hidden" id="upid" name="upid" value="{$admindetails[0].id}">
{else}
<input type="hidden" id="action" name="action" value="add_biography">
{/if}
<article class="module width_full">
<header><h3 style="color: white;"> Add Biography</h3></header>
<div class="module_content">
<fieldset>
<div><label>Name<span class="star">*</span></label>
<input type="text" id="cname" name="name" class="required" value="{$admindetails[0].name}"></div></br></br></br>
<label>Description:<span class="star">*</span></label>
<textarea cols="60" rows="5" type="text" class="required" name="description" id="description" value="{$admindetails[0].description}"></textarea></br></br></br><br><br><br><br>
<div><label>Type<span class="star">*</span></label>
<select name="type" id="type" >
<option value="personal">Personal</option>
<option value="professional">Professional</option>
</select>
</div></br>
<div><label>Image<span class="star">*</span></label>
{if $admindetails[0].image eq ''}
<input type="file" name="file" id="file" style="margin-left:10px;" accept="image/*" class="required" value="">
{else}
<input type="file" name="file" id="file" style="margin-left:10px;" accept="image/*" value="">
{/if}
</div></br>
<img src="upload/{$admindetails[0].image}" width="300" height="300" alt="">
</fieldset>
<div class="clear"></div>
</div>
<footer>
<div class="submit_link">
<input type="submit" value="Save">
<input type="reset" value="Reset">
</div>
</footer>
</article><!-- end of stats article -->
</form>

Have you try doing this..
<textarea cols="60" rows="5" type="text" class="required" name="description" id="description" >{$admindetails[0].description}</textarea>

Related

Update form to edit record in the DB PHP HTML

guys I have a problem with a PHP page.
I'm trying to make a form to update the record of a DB.
I'm displaying the form with an echo but I have some problems with quotes
<? echo'
<img src="logo.jpg">
<fieldset>
<input name="aspettogen2" type="text" value="<?php echo $aspettogen;?>">
</fieldset>
<fieldset>
<input name="desc" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="ragsoc" type="text" maxlength="100">
</fieldset>
<fieldset>
<input name="numcivico" type="text" maxlength="20">
</fieldset>
<fieldset>
<input name="validita" type="text">
</fieldset>
<fieldset>
<input name="odierna" type="data">
</fieldset>
<fieldset>
<input name="preavviso" type="text">
</fieldset>
<fieldset>
<input name="scadenza" type="text">
</fieldset>
<fieldset>
<input name="presc" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="freq" type="number">
</fieldset>
<fieldset>
<input name="datacontr" type="text">
</fieldset>
<fieldset>
<input name="proxcontr" type="text">
</fieldset>
<fieldset>
<input name="note" type="text">
</fieldset>
</form>
</div>
</body>
</html>';
in the first fieldset value="<?php echo $aspettogen;?"> it appears gray because the quote after the echo turn it into a "comment" and i cant print the value..
how can i solve it?
i've tried to do like this Value="'<?php echo $aspettogen;?'"> but i receive the error Parse error: syntax error, unexpected '?' in /var/..... on line 50
You have wrong syntax in that line. I have made the necessary changes.
Code:
<? echo'
<img src="logo.jpg">
<fieldset>
<input name="aspettogen2" placeholder="Aspetto Generale" type="text" value="<?php echo $aspettogen;?>">
</fieldset>
<fieldset>
<input name="desc" placeholder="Descrizione" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="ragsoc" placeholder="Ragione Sociale" type="text" maxlength="100">
</fieldset>
<fieldset>
<input name="numcivico" placeholder="Numero Civico" type="text" maxlength="20">
</fieldset>
<fieldset>
<input name="validita" placeholder="Validita" type="text">
</fieldset>
<fieldset>
<input name="odierna" placeholder="Data" type="data" id="today" readonly >
</fieldset>
<fieldset>
<input name="preavviso" placeholder="Preavviso" type="text">
</fieldset>
<fieldset>
<input name="scadenza" placeholder="Scadenza" type="text">
</fieldset>
<fieldset>
<input name="presc" placeholder="Prescrizioni" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="freq" placeholder="Frequenza (in giorni)" type="number">
</fieldset>
<fieldset>
<input name="note" placeholder="Note" type="text">
</fieldset>
<fieldset>
<button name="submit" type="submit" id="contact-submit">Inserisci</button>
</fieldset>
</form>
</div>
</body>
</html>';?>

Image is not posting through form post method

I am beginner in codeignitor.I want to post an image through a post method. All data is being posted but the image is not posting in controller.
Here is my view code.
<form action="<?php echo site_url('adminpanel/add_event');?>" method="post" name="addform" enctype="multipart/form-data">
<fieldset>
<p>
<label style="width:20%;float:left;">Event Title<span style="color:red">*</span>
</label>
<label style="width:1%;float:left;">:</label>
<input class="text-input small-input" type="text" name="event_title" id="event_title" placeholder="Event Title" value="<?php if(isset($teenzstore_edit_data['product_name'])) echo $teenzstore_edit_data['product_name'];?>" />
</p>
<p style="clear:both;"></p>
<p>
<label style="width:20%;float:left;">Select Age<span style="color:red">*</span>
</label>
<label style="width:1%;float:left;">:</label>
<select name="age" id="age" class="form-control" class="form-control" onChange="return get_product_filter('<?php echo base_url();?>',this.value);">
<option value="0">Select Age</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
</select>
</p>
<p style="clear:both;"></p>
<p>
<label style="width:20%;float:left;">Event Image</label>
<label style="width:1%;float:left;">:</label>
<input type="file" name="event_image" id="event_image" onchange="checkExtension(this.value)" />
</p>
<p style="clear:both;"></p>
<p>
<label style="width:20%;float:left;">Event Date<span style="color:red">*</span>
</label>
<label style="width:1%;float:left;">:</label>
<input class="text-input small-input" type="text" name="event_date" id="event_date" placeholder="Event Date" value="<?php if(isset($teenzstore_edit_data['product_points'])) echo $teenzstore_edit_data['product_points'];?>" />
</p>
<p style="clear:both;"></p>
<p>
<label style="width:20%;float:left;">Event Time<span style="color:red">*</span>
</label>
<label style="width:1%;float:left;">:</label>
<input class="text-input small-input" type="text" name="event_time" id="event_time" placeholder="Event Time" value="<?php if(isset($teenzstore_edit_data['product_points'])) echo $teenzstore_edit_data['product_points'];?>" />
</p>
<p style="clear:both;"></p>
<p>
<label style="width:20%;float:left;">Event Venue <span style="color:red">*</span>
</label>
<label style="width:1%;float:left;">:</label>
<label style="width:20%;float:left;">
<textarea cols="80" id="event_venue" style="width:77% !important;" name="event_venue" rows="10">
<?php if(isset($restaurant_edit_data[ 'rest_description'])) echo $restaurant_edit_data[ 'rest_description'];?>
</textarea>
</p>
<script type="text/javascript">
CKEDITOR.replace('event_venue', {
width: "630",
});
</script>
<p style="clear:both;"></p>
<p>
<label style="width:20%;float:left;">Event Description <span style="color:red">*</span>
</label>
<label style="width:1%;float:left;">:</label>
<label style="width:20%;float:left;">
<textarea cols="80" id="event_desc" style="width:77% !important;" name="event_desc" rows="10">
<?php if(isset($restaurant_edit_data[ 'rest_description'])) echo $restaurant_edit_data[ 'rest_description'];?>
</textarea>
</p>
<script type="text/javascript">
CKEDITOR.replace('event_desc', {
width: "630",
});
</script>
</fieldset>
<div class="clear"></div>
<p>
<label style="width:20%;float:left;"> </label>
<label style="width:1%;float:left;"> </label>
<input class="button" type="submit" name="submit" value="Submit" />
<input class="button" type="button" value="Cancel" name="cancel" onclick="javascript:history.go(-1);" />
</p>
</form>
I can't find problem, because in my computer everything works fine, but can explain you method debug:
1) Remove from your code any fragment that is not connected with problem:
I created index.html with this:
<html>
<head>
<meta lang="en">
</head>
<body>
<form action="test.php" method="post" name="addform" enctype="multipart/form-data">
<fieldset>
<hr>
<p>
<label style="width:20%;float:left;">Event Image</label>
<label style="width:1%;float:left;">:</label>
<input type="file" name="event_image" id="event_image" onchange="checkExtension(this.value)" />
</p>
<p style="clear:both;"></p>
<hr>
</fieldset>
<div class="clear"></div>
<p>
<label style="width:20%;float:left;"> </label>
<label style="width:1%;float:left;"> </label>
<input class="button" type="submit" name="submit" value="Submit" />
<input class="button" type="button" value="Cancel" name="cancel" onclick="javascript:history.go(-1);" />
</p>
</form>
</body>
</html>
Next I created file test.php in the same directory with content:
<?php
var_dump($_POST);
var_dump($_FILES);
After connecting file in form I obtained the following content:
array(1) { ["submit"]=> string(6) "Submit" } array(1) { ["event_image"]=> array(5) { ["name"]=> string(38) "image.png" ["type"]=> string(9) "image/png" ["tmp_name"]=> string(14) "/tmp/phpBQAZXv" ["error"]=> int(0) ["size"]=> int(124622) } }
Show me your result of this test. Probably problem is in processing, not in form.
Create a function in Your Controller by the name of add_event because your are posting your form data to this action. your code may like below
class adminpanel extands CI_Controller{
function add_event(){
echo $_FILES['event_image']['name'];
}
}

Nested 'post' calls inside html

If I add the first div inside the form, the submit button stops working. Must be somehow related to the nested 'post' calls and the different .php files.
<form action="register.php" method="post">
<div id="kv-avatar-errors-1" class="center-block" style="width:800px;display:none"></div>
<form class="text-center" action="/avatar_upload.php" method="post" enctype="multipart/form-data">
<div class="kv-avatar center-block" style="width:200px;text-align:center;">
<input id="avatar-1" name="profile_pic" type="file" value="" class="file-loading">
</div>
</form>
</div>
<label>Username:</label>
<input type="text" name="username" value="" />
<label>Email:</label>
<input type="text" name="email" value="" />
<label>Password:</label>
<input type="password" name="password" value="" /> <br /><br />
<input type="submit" class="btn btn-info" value="Register" />
</form>
What's the best way to fix this?
Cause form inside form is an invalid syntax. – u_mulder

PHP code in echo with html

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' ); ?>

How to keep the Log-In Form from reappearing

I'm using the PHPmotion script: http://demo.phpmotiontemplates.com/default/
and I've succeeded in getting the Log-In Form (on the home page) to disappear, once it successfully performs it's function, (which is what I'm trying to accomplish), but as soon as the Log-In function succeeds, and the "sub-menu" on the home page appears,
the Log-In Form reappears again (on the homepage).
So, I'm assuming the sub-menu has something to do with the Log-In Form reappearing.
Which looks like this:
<form action="../login.php" method="post" accept-charset="UTF-8" class="middletext"
onsubmit="javascript:this.style.display='none';">
<p>
<input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value=='ENTER USERNAME') {this.value=''; this.style.color='#696969';}" >
<input type="text" size="20" name="password_login" id="password_login" value="ENTER PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value=='ENTER PASSWORD') {this.value=''; this.style.color='#696969';}" >
<input type="hidden" name="cookie_time" value="10080" />
<img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit" style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" />
<input type="hidden" name="submitted" value="yes" />
<input type="hidden" name="remember_me" value="remember_me" />
</p>
</form>
</div>
<!--Begin Sub-Navigation. This only appears when a user is logged in.-->
<div class="container1">
<div class="menu1">
<div class="sub-nav"> <img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /> my account<img src="../themes/default/images/arrow- red.jpg" style="vertical-align:middle" alt="" />
[var.lang_my_credits]: [var.member_credits]</font><img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle">[var.login_out]
<!--[onload;block=div;when [var.loggedin]=1;comm]-->
</div>
Any thoughts/solution about this will be greatly appreciated.
<?php
if(!isset($_SESSION['YOUR-SESSION-NAME'])){
echo '<form action="../login.php" method="post" accept-charset="UTF-8" class="middletext"
onsubmit="javascript:this.style.display=\'none\';">
<p>
<input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value==\'ENTER USERNAME\') {this.value=\'\'; this.style.color=\'#696969\';}" >
<input type="text" size="20" name="password_login" id="password_login" value="ENTER PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value==\'ENTER PASSWORD\') {this.value=\'\'; this.style.color=\'#696969\';}" >
<input type="hidden" name="cookie_time" value="10080" />
<img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit" style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" />
<input type="hidden" name="submitted" value="yes" />
<input type="hidden" name="remember_me" value="remember_me" />
</p>
</form>
</div>
<!--Begin Sub-Navigation. This only appears when a user is logged in.-->
<div class="container1">
<div class="menu1">
<div class="sub-nav"> <img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /> my account<img src="../themes/default/images/arrow- red.jpg" style="vertical-align:middle" alt="" />
[var.lang_my_credits]: [var.member_credits]</font><img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle">[var.login_out]
<!--[onload;block=div;when [var.loggedin]=1;comm]-->
</div>';
} else {
echo 'You\'re already logged in!';
}
?>

Categories