color.php
<!DOCTYPE html>
<html>
<body style="padding-left:200px">
<form action="" method="post">
<br>
<br>
<div>
<label style="color:orange">Enter Text: </label>
<input type="text" name="size" placeholder="ENTER YOUR TEXT">
</div>
<br>
<br>
<div>
<label style="color:orange">Select Size: </label>
<input type="text" name="size">
</div>
<br>
<br>
<div>
<label class="control-label" style="color:orange">Font Name :</label>
<select name="font" style="margin-left:14px; color:black;">
<option disabled selected value> -- select an option -- </option>
<option>Times New Roman</option>
<option>Arial</option>
<option>Verdana</option>
<option>Georgia</option>
<option>Impact</option>
</select>
</div>
<br>
<br>
<div>
<label style="color:orange">Choose Color: </label>
<input type="text" name="size">
</div>
<br>
<br>
<input type="submit" value="submit">
</form>
</body>
</html>
Hello every one I have a very much simply question on php, I might be downvoted for this but
I am not getting any idea on how to do this, this is what im trying to do I have a field in which if I enter something for example say "I love coding" and after
entering this in the input field and later if I select any font size ,font name and color, then that entered text should be displayed with the particular values
can anyone tel me how do I start this work, im not getting any idea. please it will be helpfull if someone guides me.
it should be purely in php
You can't change html tags with php, I'm not sure but maybe you can do it with javascript
i want to get value of input of my form via $_post in my insert page but my problem is that i get error massage:undefined index:track_code and i cant get value of it.the names is same what is problem?
this is my problem why stackoverflow want more detail. this is all detail
<form action="insert.php" method="post">
<input name="track_code" type="text" class="tiny-size" value="<?php echo $track_code_rnd ; ?>" style="width: auto;height: auto" disabled />
</form>
<form action="insert.php" method="post" class="form-horizontal form-checkout">
<div class="control-group">
<label class="control-label" for="firstName">نام<span class="red-clr bold">*</span></label>
<div class="controls">
<input name="first_name" type="text" id="firstName" class="span4" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="lastName">نام خانوادگی<span class="red-clr bold">*</span></label>
<div class="controls">
<input name="last_name" type="text" id="lastName" class="span4">
</div>
</div>
<input name="submit" type="submit" class="btn btn-success" value="خرید" style="width: 66px"/>
</form>
<form action="insert.php" method="post">
<input name="track_code" type="text" class="tiny-size" value="<?php echo $track_code_rnd ; ?>" style="width: auto;height: auto" disabled />
</form>
<?php
$track_code = $_POST['track_code'];
?>
Set this one code in your form
<form action="insert.php" method="post">
<input name="track_code" type="text" class="tiny-size" value="<?php echo ($track_code_rnd)?$track_code_rnd:'';?>" style="width: auto;height: auto" disabled />
</form>
Remove disable tag from your input code. Disable controls wont be posted on server. for that you can make it readonly or make it hide
Try Putting the PHP code on the form. as given below.
<?php
if (isset($_POST['submit'])) {
$track_code = $_POST['track_code'];
}
?>
<form action="your_page.php" method="post">
<input name="track_code" type="text" class="tiny-size" value="<?php echo $track_code_rnd; ?>" style="width: auto;height: auto" readonly />
<input name="submit" type="submit" />
</form>
It will execute the whole file as PHP. The first time you open it, $_POST['submit'] won't be set because the form has not been sent. Once you click on the submit button, it will print the information.
Disabled controls never post on server. So make it readonly or hidden.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have created one HTML form and i have written php script also to connect to database. If i enter data in form and hit UPDATE button in form, its showing error like below,
<form action="process.php" method="Post"/>
<style>
p{
float:left;
}
</style>
<fieldset>
<legend align="center"><FONT color=default>Enter information Of SO's</legend>
<p align="center">
<label for="SO_ID"><FONT color=white>SO_ID</label>
<br/>
<input type="varchar" id="SO_ID" name="SO_ID"required/>
</p>
<p align="center">
<label for="No.of_samples"><FONT color=white>No.of samples</label>
<br/>
<input type="int" id="No.of_samples" name="No.of_samples"required/>
</p>
<p align="center">
<label for="Sample name"><FONT color=white>Sample name</label>
<br />
<input type="varchar" id="Sample name" name="Sample name"required/>
</p>
<p align="center">
<label for="Client name"><FONT color=white>Client name</label>
<br />
<input type="text" id="Client name" name="Client name"required/>
</p>
<p align="center">
<label for="Institution"><FONT color=white>Institution</label>
<br/>
<input type="text" id="Institution" name="Institution"required/>
</p>
<p align="center">
<label for="Run number "><FONT color=white>Run number </label>
<br/>
<input type="int" id="Run number" name="Run number"required/>
</p>
<p align="center">
<label for="Obtained reads"><FONT color=white>Obtained reads</label>
<br/>
<input type="int" id="Obtained reads" name="Obtained reads"required/>
</p>
<p align="center">
<label for="Re run Info"><FONT color=white>Re run Info</label>
<br/>
<input type="text" id="Re run Info" name="Re run Info"required/>
</p>
<p align="center">
<label for="Total reads"><FONT color=white>Total reads</label>
<br/>
<input type="int" id="Total reads" name="Total reads"required/>
</p>
<p align="center">
<label for="Run date"><FONT color=white>Run date</label>
<br/>
<input type="date" id="Run date" name="Run date"required/>
</p>
<p align="center">
<label for="Raw data location"><FONT color=white>Raw data location</label>
<br/>
<input type="varchar" id="Raw data location" name="Raw data location"required/>
</p>
<p align="center">
<label for="Analyst"><FONT color=white>Analyst</label>
<br/>
<input type="varchar" id="Analyst" name="Analyst"required/>
</p>
<p align="center">
<label for="Mentor"><FONT color=white>Mentor</label>
<br/>
<input type="text" id="Mentor" name="Mentor"required/>
</p>
<p align="center">
<label for="Analysis start date"><FONT color=white>Analysis start date</label>
<br/>
<input type="date" id="Analysis start date" name="Analysis start date"required/>
</p>
<p align="center">
<label for="Analysis end date"><FONT color=white>Analysis end date</label>
<br/>
<input type="date" id="Analysis end date" name="Analysis end date"required/>
</p>
<p align="center">
<label for="Report location"><FONT color=white>Report location</label>
<br/>
<input type="varchar" id="Report location" name="Report location"required/>
</p>
</fieldset>
<div style="text-align:center">
<button action= "process.php" method="post" >
<img alt="ok" src=
"http://www.blueprintcss.org/blueprint/plugins/buttons/icons/tick.png" />
UPDATE
</button>
</form>
the above script is saved in "process.html"
now below PHP script.
<?php
define('DB_NAME','ProcessTrackingSystem');
define('DB_USER','root');
define('DB_PASSWORD','');
define('DB_HOST','localhost');
$link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if(!$link){
die('couldnot connect:'.mysql_error());
}
$db_selected=mysql_select_db(DB_NAME,$link);
if(!$db_selected){
die('cannot use'.DB_NAME.':'.mysql_error());
}
$value1 =$_POST['SO_ID'];
$value2 =$_POST['No.of samples'];
$value3 =$_POST['Sample name'];
$value4 =$_POST['Client name'];
$value5 =$_POST['Institution'];
$value6 =$_POST['Run number '];
$value7 =$_POST['Obtained reads'];
$value8 =$_POST['Re run Info'];
$value9 =$_POST['Total reads'];
$value10 =$_POST['Run date'];
$value11 =$_POST['Raw data location'];
$value12 =$_POST['Analyst'];
$value13 =$_POST['Mentor'];
$value14 =$_POST['Analysis start date'];
$value15 =$_POST['Analysis end date'];
$value16 =$_POST['Report location'];
$sql="INSERT INTO ProcessDetails (SO_ID, No.of_samples, Sample_name, Client_name, Institution, Run_number, Obtained_reads, Re_run_Info, Total_reads, Run_date, Raw_data_location, Analyst, Mentor, Analysis_start_date, Analysis_end_date, Report_location) VALUES ('$value1', '$value2', '$value3', '$value4', '$value5','$value6', '$value7', '$value8', '$value9', '$value10','$value11', '$value12', '$value13', '$value14', '$value15','$value16')";
if(!mysql_query($sql)){
die('error:'.mysql_error());
}
header('Location:process.html');
mysql_close();
?>
now if i enter the data into html form, its showing error that "error:Unknown column 'No.of_samples' in 'field list'".
anyone help me out to fix this error and get desired output.
Thanks in advance....
Assuming that a No.of_samples column exists in your table, quote the name with backticks (`) in your query:
$sql="INSERT INTO ProcessDetails (SO_ID, `No.of_samples`, Sample_name, Client_name, Institution, Run_number, Obtained_reads, Re_run_Info, Total_reads, Run_date, Raw_data_location, Analyst, Mentor, Analysis_start_date, Analysis_end_date, Report_location) VALUES ('$value1', '$value2', '$value3', '$value4', '$value5','$value6', '$value7', '$value8', '$value9', '$value10','$value11', '$value12', '$value13', '$value14', '$value15','$value16')";
Also, you might want to look into SQL injection security risks, and into using the non-deprecated mysqli_* functions instead of the deprecated mysql_* ones.
You are inserting to column No.of_samples which does not exist!
I have a form with a simple file upload input like:
<div class="contenttitle radiusbottom0">
<h2 class="finfo"><span>Uploader</span></h2>
</div>
<p>
Chose your file: <input type="file" name="uploaded_file" />
</p>
the rest as well, is a very simple form. Now when I execute (submit) this form it takes about 30 seconds to process it. Even when I don't choose any file to upload.
When I remove the file input from the form then it takes 1 second max. I add it back and it takes a lot of time again. The action page does not matter. What could be the problem?
here is the complete form:
<div class="boxwhite">
<form class="stdform" enctype="multipart/form-data" method="post" action="">
<div class="two_third">
<p>
<label>Header</label>
<input type="text" name="title" id="firstname" class="longinput" value=""/>
</p>
</div>
<div class="one_third">
<p>
<label>Status</label>
<select name="status">
<option value="1" <?= $content[status]==1?'selected':'' ?> >Active</option>
<option value="0" <?= $content[status]==0?'selected':'' ?> >Pasive</option>
</select>
</p>
</div>
<br clear="all" />
<input type='hidden' name='parent_id' value='3' />
<div class="contenttitle radiusbottom0">
<h2 class="finfo"><span>Uploader</span></h2>
</div>
<p>
Chose your file: <input type="file" name="uploaded_file" />
</p>
<BR />
<input type="submit" name="submit" value="Add" class="" />
<button class="cancel radius2">Cancel</button>
</form>
</div>
(this files are on a windows server)
I have moved the work to a linux server. Everything works fine now.
I'm trying to pre-populate my form values with variables passed through the URL.I've tried many different solutions, sometimes I don't get an error, the variable just doesn't show up. Any help is appreciated, thanks!
URL Example: website.com/?firstname=john
Code:
<html>
<script type="text/javascript">
function writeform(){
selobj = document.getElementById('selform');
newobj = document.getElementById('newform');
p = document.getElementById('menu').selectedIndex + 1;
a = document.getElementById('menu2').selectedIndex + 1;
if((p < 14 && (a == 1 || a == 2 || a == 3 ||a == 4)) { // write the 1st form
txt = 'Person 1: '+'<input type="text"/><br/>';
txt += 'Person 2: '+'<input type="text"/>';
} else {
document.getElementById('div1').style.display='block';
}
// if(p==2 && a==1){ // write the 2nd form
// txt ='Name: '+'<input type="text"/><br/>';
// txt+='Addr: '+'<input type="text"/>';}
newobj.innerHTML=txt;selobj.style.display='block';
}
</script>
<div style="width: 400px; float:left;"> <?php echo $_GET["firstname"]; ?></div>
<div style="width: 400px; float: left;"> <!-- Primary Div-->
<p style="font-size: 16px; font-weight: bold;">Select Something</p>
<div class="fancy3">
<table style="width:350px; height=350px">
<tr>
<td>
<select id="menu" size="14">
<option selected="selected"><b>--- Common Options ---</b></option>
<option></option> //NY
</select>
<br/>
<p style="font-size: 16px; font-weight: bold;">Range</p>
<div class="fancy3">
<table style="width:350px; height=350px">
<tr>
<td>
<select id="menu2" size="4">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<br/>
</td>
<td>
<div id="selform" style="display:none">
<fieldset>
<div id="newform"></div>
</fieldset>
</div>
</td>
</tr>
</table>
</div>
<br/>
<button onclick="writeform();">Search</button></td>
<td>
<div id="selform" style="display:none">
<fieldset>
<div id="newform"></div>
</fieldset>
</div>
</td>
</tr>
</table>
</div>
</div> <!-- Primary Div closing tag-->
<!-- of Field-Specific Forms-->
<div id="div1" style="display:none;">
<form action="http://site1.com/upload" method="get">
First Name: <input name="fname" type="text" value="" />
Last Name: <input name="lname" type="text" />
Address: <input name="address" type="text" />
Zip Code: <input name="zip" type="text" />
State: <input name="state" type="text" />
<input type="submit" />
</form>
</div>
<div id="div1" style="display:none;">
<?php
$firstname = $_GET["firstname"];
?>
<form action="http://site1.com/upload" method="get">
First Name: <input name="fname" type="text" value="<?php $firstname = $_GET["firstname"]; echo "$firstname"; ?>" />
Last Name: <input name="lname" type="text" />
Address: <input name="address" type="text" />
Zip Code: <input name="zip" type="text" />
State: <input name="state" type="text" />
<input type="submit" />
</form>
</div>
<?php $firstname = $_GET["firstname"]; echo "$firstname"; ?>
</html>
Test that what you get in $_GET variable by using var_dump($_GET), then use:
echo isset($_GET["firstname"]) ? $_GET["firstname"] : "";
Firstly use print_r($_GET) at the begining of the file to check wether you have the parameters passed.
Then you might want to clean up that mess, because defining $firstname 3 times with the same value just to echo it out makes no sense.
Secondly, you would really like to change those action url as I'm pretty sure it's wrong:
<form action="http://site1.com/upload" method="get">
Thirdly, your input names are name="fname" meanwhile using firstname in $_GET. Not really sure if you will ever relate these two but, whatever.
Some advices:
learn to write code quite more readable than this.
go to jQuery.com and do some research, as it really helps you write less , do more.
CSS doesn't use equal (=) sign as value setter , which in your case is height=350px when it should be height: 350px;.
Give elements some ID's or Classes and use some .css files , it will clean your code more than you can imagine.
You had started wrongly, that's why URL doesn't appering
<script type="text/javascript">
function writeform(){
selobj=document.getElementById('selform');
newobj=document.getElementById('newform');
p=document.getElementById('menu').selectedIndex+1;
a=document.getElementById('menu2').selectedIndex+1;
if((p<14 && (a==1 || a==2 || a==3 ||a==4)){ // write the 1st form
txt ='Person 1: '+'<input type="text"/><br/>';
txt+='Person 2: '+'<input type="text"/>';} else {
document.getElementById('div1').style.display='block';
}
// if(p==2 && a==1){ // write the 2nd form
// txt ='Name: '+'<input type="text"/><br/>';
// txt+='Addr: '+'<input type="text"/>';}
newobj.innerHTML=txt;selobj.style.display='block';}
</script>
<body>
<form action="http://site1.com/upload" method="get">
<?php echo $_GET["firstname"]; ?>
<p style="font-size: 16px; font-weight: bold;">Select Something</p>
<div class="fancy3"><table style="width:350px; height=350px">
<tr><td><select id="menu" size="14">
<option selected="selected"><b>--- Common Options ---</b></option>
<option></option> //NY
</select><br/>
<p style="font-size: 16px; font-weight: bold;">Range</p>
<div class="fancy3"><table style="width:350px; height=350px">
<tr><td><select id="menu2" size="4">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option></select><br/>
</td>
<td><div id="selform" style="display:none">
<fieldset><div id="newform"></div></fieldset></div>
</td></tr></table></div>
<br/>
<button onclick="writeform();">Search</button></td>
<td><div id="selform" style="display:none">
<fieldset><div id="newform"></div></fieldset></div>
</td></tr></table></div>
</div> <!-- Primary Div closing tag-->
<!-- of Field-Specific Forms-->
<div id="div1" style="display:none;">
<form action="http://site1.com/upload" method="get">
First Name: <input name="fname" type="text" value="" />
Last Name: <input name="lname" type="text" />
Address: <input name="address" type="text" />
Zip Code: <input name="zip" type="text" />
State: <input name="state" type="text" />
<input type="submit" />
</form>
</div>
<div id="div1" style="display:none;">
<?php
$firstname = $_GET["firstname"];
?>
First Name: <input name="fname" type="text" value="<?php $firstname = $_GET["firstname"]; echo "$firstname"; ?>" />
Last Name: <input name="lname" type="text" />
Address: <input name="address" type="text" />
Zip Code: <input name="zip" type="text" />
State: <input name="state" type="text" />
<input type="submit" />
</form>
</div>
<?php $firstname = $_GET["firstname"]; echo "$firstname"; ?>
</body>
</html>
A couple of problems that I'm seeing here ... for one you have multiple elements with the same id (see id="selform").
To load get variable into a text input the pattern is like this:
<input type='text' name='fieldname' value='<?= isset($_GET['field'])?$_GET['field']:"") ?>'/>
for a checkbox or radio control it is like this
<input type='checkbox' name='fieldname' value='myval' <?= isset($_GET['field']) && $_GET['field'] == 'myval'?"checked=\"checked\"":"") />
for select boxes it you do this:
<select name='fieldname'>
<option value='myval' <?= isset($_GET['field']) && $_GET['field'] == 'myval'?"selected=\"selected\":"" ?>>My Val Label</option>
<option value='myval2' <?= isset($_GET['field']) && $_GET['field'] == 'myval2'?"selected=\"selected\":"" ?>>My Val2 Label</option>
</select>
Here is a nifty select box function that will allow you too more concisely output a select in your code (i find the check with every element a little tedious)
function showSelect($name, $options, $selected, $attr = array()){
$str = "<select name='".$name.'"';
foreach($attr as $name=>$val){
$str.= " ".$name."='".$val."'";
}
$str.=">";
foreach($options as $k=>$val){
$str.= "<option value='".$val."'".($val==$selected?" selected='selected'":"").">".$k.'</option>';
}
$str.="</select>";
}
and you can use it like this...
$days = array();
for($d = 1; $x<=31; $x++){
$days[(string)$d] = (string)$d;
}
echo showSelect("formDays", $days, $_POST["formDays"], array("id"=>"formDays"))