I am trying to concatenate this code but i can not do it right
echo '<input type="text" id="text" name="username"
value=".<?php if(isset($_COOKIE['.'rememberme'.']))
{echo $_COOKIE['.'remember me'.'];}?>."
placeholder="Username"/><br />';
You're already in PHP there...
<?php
echo '<input type="text" id="text" name="username"';
if( isset($_COOKIE['rememberme'])) echo ' value="'.htmlspecialchars($_COOKIE['rememberme']).'"';
echo ' placeholder="Username" /><br />';
printf('<input type="text" id="text" name="username" value="%s" placeholder="Username"/><br />',
(isset($_COOKIE['remember_me'])) ? htmlspecialchars($_COOKIE['remember_me']) : ''
);
Related
I am new to codeigniter and i want to run my sms web service code in view when user insert number.
but the post method is empty! can anyone help me?
var_dump($_POST['sendSms']);exit;
if(array_key_exists('sendSms', $_POST)) {
sendSms();
}
function sendSms(){ //my sms web service code}
echo '<form method="Post" action= "http://crm.oynarco.ir/admin/settings?group=sms">';
?>
<input type="hidden"
name="<?php echo $this->security->get_csrf_token_name()?>"
value="<?php echo $this->security->get_csrf_hash()?>">
<?php
echo '<input type="hidden" name="username" value="09172030433"/><br />';
echo '<input type="hidden" name="password" value="Oynar1234" /><br />';
echo '<input type="text" name="to" class="form-control test-phone" placeholder="'._l('staff_add_edit_phonenumber').'" /><br />';
echo '<textarea type="text" name="text" class="form-control sms-gateway-test-message" placeholder="'._l('test_sms_message').'" ></textarea><br />';
echo '<input type="text" name="From" class="form-control" value="5000203069627" /><br />';
echo '<input type ="submit" name="sendSms" class="btn btn-info send-test-sms" value="'._l('send_test_sms').'" />';
echo '</form>';
in action root to controller then in controller get the post method and add your sms function.
?>
<form method="Post" action= "settings/sendSms">
<input type="hidden"
name="<?php echo $this->security->get_csrf_token_name()?>"
value="<?php echo $this->security->get_csrf_hash()?>">
<?php
echo '<input type="hidden" name="username" value = "09172030433"/><br />';
echo '<input type="hidden" name="password" value ="Oynar1234" /><br />';
echo '<input type="text" name="to" class="form-control test-phone" placeholder="'._l('staff_add_edit_phonenumber').'" /><br />';
echo '<textarea type="text" name="text" class="form-control sms-gateway-test-message" placeholder="'._l('test_sms_message').'" ></textarea><br />';
echo '<input type="text" name="From" class="form-control" value = "5000203069627" /><br />';
echo '<input type ="submit" name="sendSms" class="btn btn-info send-test-sms" value = "'._l('send_test_sms').'" />';
echo '</form>';
in controller:
public function sendSms(){
//var_dump($_POST);exit;
if (isset($_POST) ){
//send sms
}
I want to see all field input and textarea but I don't know how to
show it together in the same code.
and in case I want to skip something for example I want to write
directly input name without make him check the type or I don't want him to show me the readonly so how can I do it ?
<form method="post" action="" id="submit_form">
<input type="text" name="TITLE" value="" size="40" maxlength="100" class="text" />
<textarea name="DESCRIPTION" rows="4" cols="36" class="textarea"></textarea>
<input type="text" name="DESCRIPTION_limit" size="4" class="limit_field" readonly="readonly" value="250" />
<textarea name="ARTICLE" id="ARTICLE" rows="6" cols="50" class="textarea"></textarea>
<input type="text" name="META_KEYWORDS" value="" size="40" maxlength="2000" class="text" />
preg_match_all('/<(input)[\s](type)="?([^>"]*)"?[\s](name)="?([^>"]*)"?[\s]/', file_get_contents($url), $matches);
echo"<pre>";
print_r($matches);
I tested this code with the line "$string". Type and Name attributes can be in any order in the input tag, and it searches until it reads a ">" character.
$string = '<input type="text" name="TITLE" value="" size="40" maxlength="100" class="text" />';
preg_match_all('/<input[^>]*?(?:(type)="([^"]*)")|(?:(name)="([^"]*)")/', $string, $matches);
if($matches[1][0] == "type" && $matches[3][1] == "name"){
$type = $matches[2][0];
$name = $matches[4][1];
}
elseif($matches[1][0] == "name" && $matches[3][1] == "type"){
$name = $matches[2][0];
$type = $matches[4][1];
}
else{
throw new Exception('no input tags with type and name attributes were found!');
}
echo $type;
echo $name;
I have a form in HTML, and it stores data into array structure.
echo '<input type="text" style="text-align:right;" size="5" name="row[1][kidname]" />';
echo '<input type="text" type="number" style="text-align:right;" size="5" name="row[1][kidweight]" />';
echo '<input type="text" type="number" style="text-align:right;" size="5" name="row[1][kidheight]" />';
echo '<input type="text" style="text-align:right;" size="5" name="row[2][kidname]" />';
echo '<input type="text" type="number" style="text-align:right;" size="5" name="row[2][kidweight]" />';
echo '<input type="text" type="number" style="text-align:right;" size="5" name="row[2][kidheight]" />';
Supposed I need to get the second kid's weight value, how should I do? I have tried:
$_POST[row[2][kidweight];
$_POST['row[2][kidweight'];
You can try also.
$_GET['row'][2]['kidweight'];
I want to style these echo statements like a login form. How can I style these echo statements?
echo '<form action="login.php" method="post"><input type="hidden" name="ac" value="log"> ';
echo 'Username: <input type="text" name="username" />';
echo 'Password: <input type="password" name="password" />';
echo '<input type="submit" value="Login" />';
echo '</form>';
Try Following snipets
echo '<style>.testclassName{ text-align:right; }</style>';
echo '<form action="login.php" method="post"><input type="hidden" name="ac" value="log"> ';
echo 'Username: <input type="text" name="username" class="testclassName"/>';
echo 'Password: <input type="password" name="password" />';
echo '<input type="submit" value="Login" />';
echo '</form>';
I am echo values by the codes below. but i want to create for each values form for saving to database.
How can i insert form inside echo ?
I am beginer in php and i want form like this and it must replace with all echo values.
----FORM----
Thumbnail url :
url :
description:
submit Button
----FORM----
this is the code
foreach($posts as $post){
if ($post){
echo $post->thumbnail . "<br />";
echo $post->url . "<br />";
echo $post->description . "<br />";
}
}
I solved how to add.
foreach($posts as $post){
if ($post){
echo '<input id="title" class="form-control" type="text" name="title" value="'.htmlspecialchars($post->thumbnail).'">';
echo '<input id="teaser" class="form-control" type="text" name="teaser" value="'.htmlspecialchars($post->Url).'">';
echo '<input id="text" class="form-control" type="text" name="text" value="'.htmlspecialchars($post->description).'">';
echo '<button class="btn btn-primary" type="submit">add</button>';
}
}
this works fine... My second question is how i can add the code below codes to inside echo in a same way ?
i tried to add same way but (if isset line ) gives error
<input type="hidden" name="mode" value="news" />
<input type="hidden" name="edit_news_submit" value="true" />
<?php if(isset($edit_news['id'])): ?>
<input type="hidden" name="id" value="<?php echo $edit_news['id']; ?>" />
<?php endif; ?>