PHP - Help, How To Display The Form Entries In A Textarea Field
hi im trying to display the form entities in the textarea field so they can be sent to the user in an email, but its not working properly it prints out the variable $idName instead of its value?? any help would be greatly appricated ive been stuck on this bit of ages
<?php function display_output_page() { $idName = trim($_REQUEST['username']); $firstName = trim($_REQUEST['firstname']); $Surname = trim($_REQUEST['surname']); $Address = trim($_REQUEST['address']); $Email = trim($_REQUEST['email']); $Phone = trim($_REQUEST['phone']); $Fitness = isset($_REQUEST['fitness']) ? $_REQUEST['fitness'] : ''; $goGym = isset($_REQUEST['gogym']) ? $_REQUEST['gogym'] : ''; $whyGym = isset($_REQUEST['whyGym']) ? $_REQUEST['whyGym']: array(); ?> <html> <head><title>Form Results</title></head> <body> <h1>Form Results</h1> <form action='mailto:$Email?subject=user comments' method='post'enctype='text/plain'> <textarea name='Topic' rows=15 cols=90> idName: ". $idName\n; Firstname: ". $_POST["firstname"]\n; Surname: ". $_POST["surname"]\n; Address: ". $_POST["address"]\n; Email: ". $_POST["email"]\n; Phone no.: ". $_POST["phone"]\n; Your fitness level: ". $_POST["fitness"]\n; How often do you go to the gym: ". $_POST["goGym"]\n; Why do you go to the Gym: ". $_POST["whyGym"]; </textarea></br> <input type='submit' value='Send Thru Email'> </form> </body> </html> <?php } ?> Similar Tutorials(Another quite newbie...) I have already an online booking form. The Form works fine now and I would like to add on one more issue, but the code ignores what I want to check. I have 4 fields: arrival, departure, no. of persons and comments to check. Scenario 1: All field mentioned above are emtpty: Workes fine and message appears: "You have not provided any booking details". Scenario 2: If arrival (date_start) and departure (date_end) is entered, there should be at least an entry either in the field "comment", or in the field "pax". If not, there should be a message: "You have not provided sufficient booking details". INSTEAD: The booking request is sent, which should not be the case. The code is currently: # all fields empty : arrival, departure, pax and comments - error if(empty($data_start) && empty($data_end) && empty($pax)&& empty($comment)){ exit("You have not specified any booking details to submit to us. <br>Please use your browser to go back to the form. <br>If you experience problems with this Form, please e-mail us"); exit; } #If arrival and departure date is entered, there should be at least an entry either in the field "comment", or in the field "pax". if(!isset($data_start) && !isset($data_end) && empty($pax) && empty($comment)){ exit("You have not provided sufficient booking details. <br>Please use your browser to go back to the form. <br>If you experience problems with this Form, please e-mail us"); exit; } The form can be tested at http://www.phuket-beachvillas.com/contact-own/contact-it.php Can someone please check and tell me what's wrong with the code ? Thanks to anyone for any hint. I know that there is a way to this with javascript, but I don't know how it would work. I am much more familiar with php so I figured I would ask here to see if anyone might have a good php solution. I'm trying to have a form text field display depending on whether or not the user checks a specific box, but I'm not sure where to start. I've searched around but I didn't find anything that would help. Basically I want to have a checkbox that asks if the user would like to link their account to an email address. If the checkbox is selected, a textbox will then appear on the page for them to enter an email address. Can anyone point me in the right direction on where to start? Thanks for your help. Hello JS experts,
I'm new to JS coding (self-learning) and I have just one (potenitally) simple request to ask of you wonderful folks here.
Oh BTW, I've tried searching through this forum (and the WWW as well) but couldn't seem to easily find something that fits my request, or was easy for me to understand and apply to my situation.
So what I have/want is: a Data-Entry form which (for the first record/entry for a given date) allows the user to select a date from a "Calendar Date Picker". Upon subsequent records/entries (for the same date), the date field should no longer be accessible, but the (previously entered/selected) value should be both displayed (greyed-out) and certainly carried over to the DB/Table.
I know this might be a very simple piece of code, but being that I'm a newbie, I'm not sure how to achieve this.
Would appreciate any and all help to get this done (preferably the necessary code).
If it helps, here's some of my existing code that's related to the field names:
Form field details:
<div class="control-group"> <label class='control-label'>Select Flyer Start Date:</label> <input type="text" name="datepicker" id="datepicker"> </div>DB (table) field details: $flyerDateStart = isset($_POST["datepicker"]) ? $_POST["datepicker"] : "";Thanks much. Hello, I am using the following code to display images managed by a MySQL database. Basically another program manages a bunch of images, but this script displays certain ones (ones with INCLUDE = 1 in the database) on my main page. My question is, is there an easy way to limit the number of images it displays, say to 5? I'm not too concerned which images actually display (ascending or descending)... or better yet, random! Most importantly, I only want five to display. Each image will be linked to the full page, which displays all the images. Any ideas? Thanks! Code: [Select] <?php $username="XXXXXXX"; $password="XXXXXXX"; $database="XXXXXXX"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ft_form_12 WHERE col_24='1'"; // $query="SELECT * FROM ft_form_12"; // SELECT * FROM ft_form_12 WHERE col_24='1' $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <?php $i=0; while ($i < $num) { $f20=mysql_result($result,$i,"col_23"); //Photo file name $f21=mysql_result($result,$i,"col_24"); //INCLUDE ?> <a href="http://www.domain.com/display_whole_page.shtml"><img src="http://www.domain.com/the_file/pictures/<?php echo $f20; ?>" height="50" border="0"></a> <?php $i++; } ?> Hi all, I wonder if anyone can give me some idea; I have a form with a drop down menu [BT,Virgin, None, Other] - When user select either [BT, Virgin,None] the textarea field will be disable. But when user select option [Other] the textarea will be available. How can I do this? .. .. <tr align="left" valign="top" <?php if ($_POST['action'] == "register") { if ($errornum[16] == "1") { echo 'class="error"'; } } ?>> <td>Who is your previous Internet Service Provider?</td> <td align="left"> <select name="oldprovider"> <option value="<?php echo $prev_supplier;?>" <?php if ($_POST['action'] == "register") { if ($_POST['oldprovider'] == "") { echo "selected"; } } ?>> Select Provider..... </option><?php $prev_supplier="BT";?> <option value="<?php echo $prev_supplier;?>" <?php if ($_POST['action'] == "register"){ if ($_POST['oldprovider'] == "$prev_supplier") { echo "selected"; } } ?>> <?php echo $prev_supplier;?> </option><?php $prev_supplier="Virgin";?> <option value="<?php echo $prev_supplier;?>" <?php if ($_POST['action'] == "register") { if ($_POST['oldprovider'] == "$prev_supplier") { echo "selected"; } } ?>><?php echo $prev_supplier;?> </option><?php $prev_supplier="None";?> <option value="<?php echo $prev_supplier;?>" <?php if ($_POST['action'] == "register") { if ($_POST['oldprovider'] == "$prev_supplier") { echo "selected"; } } ?>><?php echo $prev_supplier;?> </option><?php $prev_supplier="Other";?> <option value="<?php echo $prev_supplier;?>" <?php if ($_POST['action'] == "register") { if ($_POST['oldprovider'] == "$prev_supplier") { echo "selected"; } } ?>><?php echo $prev_supplier;?> </option> </select> <br /><br /> <textarea name="oldprovider_text" cols="30" rows="2"> <?php if ($_POST['action'] == "register") { echo $_POST['oldprovider_text']; } ?> </textarea></td> </tr> Thanks in advance. Hello, this is my first post here.
I am trying to output the rows of a certain query in sequence after a POST has been requested.
I have been successful in getting the output in a pure php file but when I try to implement this in a web page with html/css, I can't echo the array in arbitrary locations after the post has processed.
This is the code which outputs successfully in a pure php file, but I need it to work in a <textarea> field as the results of a search
$rows2 = array(); $rows3 = array(); while($stmt->fetch()){ $rows2[] = $stratoparse; $rows3[] = $date; } $search = array(); for($i=0;$i<=$num_rows;$i++){ echo $rows3[$i].' '.$rows2[$i].'<br>'.'<br>'; } }To further iterate what I am asking. When errors are stored, you write something like $errors['username']="A username is required.";Then in any location of a webpage I can call this or show it, provided by this <?php isset($errors['username']) ? $errors['username']:" ");?>That is the same thing I am trying to do with this array which can be an arbitrary count of rows... I have not been successful in getting this to work... I have been told of string concatenation... I don't know what to do Thank you for any help Hi, PHP newbie here, and my first post. I am in the process of learning PHP. Currently I am looking at forms and DB input. I would like to verify if my current method of keeping the linebreaks from a TEXTAREA field, and still keep the DB input safe is correct. I use the following code to get the input from the TEXTAREA field. Code: [Select] $comments = mysql_real_escape_string(nl2br(filter_var($_POST["comments"], FILTER_SANITIZE_STRING)));Is this the correct way of handling this? Thanks Or something like that... I am not sure how to put this.. Anyway, I'll just get started with explaining my problem. I have an admin-page in which you can delete the comments given on blogs, using checkboxes and clicking on a button with the value 'verwijderenSubmit'. The deletion part works just fine, nothing wrong. However, I also want to be able to EDIT the comments with an other button called 'bewerkenSubmit', using the same checkboxes that I use for deletion. Selecting the right CID (CommentID) is no problem, because that works the same as the deletion-part, but selecting the right textarea to update into the database is the problem... I uploaded a file here with the whole code: http://dhost.info/ddfs/myproblem.html I escaped the textarea within with square brackets, because otherwise the whole textarea would screw up.. I also added <!-- RELEVANT CODE --> to select the parts that I need to change. Well, I hope you understand my problem and can help. Hello, Hopefully I can ger som help here I have been googling this for months and seem to cant find anything that will help me out. I am trying to create a form (which is the easy part) but I want this form to send multiple entries at once from what I gather so far I need to use for each and/or loop which i am not familiar with it with my lack of knowledge........ what I have so far is Table= locations fields are id state county city the form is set up as follows state county city city city city city city city city city city city city The reason for so many cities is so i can update all cities in one county at the same time saving time I am not sure if its % doable in the manner i would like it to be done but i hope so ok i enter the state and county then i enter the cities i want i submit the form i want it to create the state/county and the first city with the next id # then enter the state/county and next city and id#. please some help me if u need to see my file let me know and ill post it im just not sure which one you need i believe it will be the save.php file but i also have the create.php file which is the form itself Thanks anyone for the help i can get Hello. How can I have a single form which has a number of standard fields in it, say date and name.... but for that same date and name I want to add multiple additional entries for say phone calls recieved... (silly example I know) How can I enter the standard data once and an undefined amount of phone calls received ? without having to put a maximum number of possible entry fields on the page.... ? So, say my Form is : <form action="myform.php" method="post"> <p>Date: <input type="text" date="date" /><br /> Name: <input type="text" name="name" /></br> Call From: <input type="text" call_from="call_from" /></br> <p><input type="submit" value="Send it!"></p> </form> If I have 50 calls for that person I only want to enter their name and the date once and then add as many calls as needed... How can I do it? Thanks Ubuntu PHP Mysql So I got this form validator script online and I applied the validator part of it to my own form. My form requires a NAME and a SERIAL to be inputted and the SERIAL must be all numbers. I tested the validator by leaving NAME blank in my form and SERIAL all letters. The dispalyed resutls show the correct error messages: "Name : Please fill in a name for this computer." and "Serial : Please fill in a serial number for this computer." But the entry is still submitted with the errors and all. Here is my validator script. It begins by calling the script I got online which is from this website: http://www.html-form-guide.com/php-form/php-form-validation.html <?PHP require_once "formvalidator.php"; $validator = new FormValidator(); $validator->addValidation("Name","req","Please fill in a name for this computer."): $validator->addValidation("Serial","req","Please fill in a serial number for this computer"); $validator->addValidation("Serial","num","Serial number must be only numeric values"); if($validator->ValidateForm()) { echo "<h2>Validation Success!</h2>"; } else { echo "<B>Validation Errors:</B>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<p>$inpname : $inp_err</p>\n"; } } } ?> Hi all,
Its been a long time since last help request from real professional from here but I'm again in trouble with a much more spectacular plan I'm working on. For those who are interested in the plan then here it is: My Idea was to make a new build starting from scratch and make it as dynamical as possible. So my goal is not to make almost anything fixed in the code. I have made a decision to make a one supper large table for multiple different entries so no more joining and no more views for me.! In this help request I'm having trouble with Posting values to a page processing page lets call it record_changer.php The sole purpose of this file is to get form posts and decide what to do. Either update, delete, or insert. record_changer.php <?php include '../../config/config.inc.php'; if(is_ajax()){ # Checks if action value exists if(isset($_POST["action"]) && !empty($_POST["action"])){ $action = $_POST["action"]; # Switch case for value of action switch($action){ case "insert": datatable_insert_function(); break; case "update": datatable_update_function(); break; case "delete": datatable_delete_function(); break; } } } # Function to check if the request is an AJAX request function is_ajax(){ return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; } function datatable_insert_function(){ } function datatable_update_function(){ } function datatable_delete_function(){ } ?>The problem. The problem is that the $insert places two entries to the DB. I cant seem to understand why.? # Test _POST values $_POST['UserID'] = '2'; $_POST['WorkID'] = '22'; $_POST['Status'] = '1'; $_POST['Code'] = '1'; $_POST['Title'] = '1'; $columns = array(); foreach(array_keys($_POST) as $name){ # Exclude Action and ID if($name == 'Action' || $name == 'ID' || $name == 'submit' ){ continue; } $columns[] = $name; } print_r($columns); echo "<br>"; $data = array_fill_keys($columns, 'NULL'); print_r($data); foreach($data as $key => $value){ $data[$key] = empty($_POST[$key]) ? 'NULL' : "'".mysql_real_escape_string($_POST[$key])."'"; } echo "<br>"; print_r($data); $insert = mysql_query('INSERT INTO datatable (ID, '.implode(', ',$columns).')VALUES (null, '.implode(',',$data).')') or die(mysql_error());No errors no nothing. Just two entries of correct data. PS. Sorry for a lot of prints in the code it is work and idea in the progress. The posts at the moment are fixed in the code so it is easier to refresh and debug. Please help if you spot the problem. Im really out of ideas. Some fresh eyes might make a difference. And Please for those who want to say it is a bad idea and why and why and so on.. Move a long.!!! Im not interested in whinging i have a great use for this and just having trouble with the two entries. Thanks. Edited by ztimer, 14 January 2015 - 03:27 PM. Hi, I am new to the boards and php and mysql. I have created a database and can add entries via a form. I can query the database with another form and get the results to display in a table. All good so far as that is what I was hoping to achieve but one of the fields I want to display as a hyperlink but I am having problems with the syntax as I keep getting errors when I try to wrap the variables in <a href > tag. Code: [Select] <tr> <td><?php echo $fquery['prefix']; echo $fquery['website']; ?><?php echo $fquery['website']; ?></td> </tr> now that displays e.g. http://www.example.comwww.example.com. so I feel I am nearly there I just need advice as to how to construct a hyperlink from the fields queried. I would like to echo field names in my table on webpage one by one. I know mySQL has "describe" function which will list the complete table, I am looking for a way to display each field name one by one with other stuff in between them like input field or description. Howdy, I'm trying to display text from a table in a database. It's a list of quotes, so I just need to pull out the quote and the author name. However, the quote and name are not fields in the same record; they are separate records. Example data: Code: [Select] quoteid name value 1 content You guys are great! Thanks for being awesome. 1 author John Jackson 2 content Gosh you're amazing! Always been so darn helpful! 2 author Peter Davis So, I just need to rip out the data from 'content' and 'author', and then group them together based on the quoteid. This is my code thus far: $testimonial_resource = mysql_query("SELECT name, value FROM quotes GROUP BY quoteid ORDER BY author ASC") or die(mysql_error()); while ($testimonial = mysql_fetch_assoc($testimonial_resource)) { echo '<p>'.$testimonial['value']'.<br /><strong>'.$testimonial['value'].'</strong></p>'; } Any help would be greatly appreciated for this novice. Cheers. Hi, I'm new to PHP so sorry if it is difficult to understand my question. I've just added a new custom field for my website home page (home.php). I've image link inside that custom field and now I want to display that image at Home (Home.php ). Please let me know what code/loop should I add in home.php to get that image display with size of 100*50 px . I hope you understand what I meant to. Thank You. Hi guys, I have a problem. I need to create a page that has a web form to upload an image to a mySQL database and place it in a blob field. Then I need to be able to query the database later to display the image on the site. I've looked around but I just haven't found any examples that can help me. Does anyone know of any good example or can anyone please give me an example? I have nothing so far, just the html web form and database. I have a form where people have to fill in some fields and send an email. When there is an error the user has to go back to the form with: Code: [Select] if (!isset($_POST['checkbox'])) { $msgToUser = '<br /><br /><font color="#FF0000">You did not add any recipients!<br><a href="javascript: history.go(-1)">Go Back</a></font>'; include_once 'msgToUser.php'; exit(); } I want to save the data that has been filled in the textarea so he doesn't have to type eveything again. I tried several options but the textarea keeps getting blank. Code: [Select] <?php $message = isset($_POST['message']) ? $_POST['message'] : ''; $fhtml = "<p>Welcome <b>'$logOptions_username'</b> write your email here. <a href=\"#\" onclick=\"return false\" onmousedown=\"javascript:toggleViewFlags('country_flags');\">Add Recipients</a> <br> </p><input type=hidden name=post value=yes><p> Subject:<br> <input type=text name=name size=100> </p> <p> Message:<br> <textarea name=message rows=10 cols=75>$message</textarea> </p> <p> <input type=submit name=submit value=\"Send\"> $sendMsg </p> "; echo $fhtml; ?> This code is apparently not working. Marco Hi everyone, I have a form which is repopulated with cookies of user entries following an unsuccessful submit. It works on all fields except the textarea which is just blank. Can anybody suggest why this isn't working? Here is the form page code: Code: [Select] <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <?php include("functions.php"); getcompanyname(company); ?> <html> <head> <title>Nominate <?php echo getuserdetails("company", company); ?> for The WOW! Awards</title> <link href="mobile.css" rel="stylesheet" type="text/css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script type="text/javascript" src="javascript/form.js"></script> </head> <div id = "header"> <img src="images/mobile_banner.png"); </div> <div id="content"> <?php mobileerror(); ?> <h2>NOMINATE US!</h2> <div id = "rulesheading"> <b>There are just four criteria to be met:</b><br /> </div> <div id = "rules"> <ol> <li>It has to be for service that made you go WOW!</li> <li>It should be a recent experience</li> <li>It must have happened to you personally</li> <li>Employees of LoveFilm may not nominate</li> </ol> </div> <form id= "contactform" action="mobile_proc_nominate.php" method="post"> <fieldset><legend>Nomination Form</legend> <input type="hidden" name="type" value="nomination"/> <input type="hidden" name="jobtitle" value=" "/> <input type="hidden" name="department" value=" "/> <input type="hidden" name="mobile" value="1" /> <h4>Your Nomination Details</h4> <p> <?php if (!isset($_COOKIE['nominee'])){ ?> <!-- These stop the Java labels overwriting user text if error --> <label for="nominee">Tell us who WOW!ed you today (required)</label> <?php } ?> <input type="text" name="nominee" id="nominee" value="<?php echo readcookie('nominee'); ?>" title="Tell us who WOW!ed you today"/> </p> <p> <?php if (!isset($_COOKIE['comment'])){ ?> <label for="comment">How, where and when did they WOW! you? (required)</label> <?php } ?> <textarea name="comment" id="comment" value="<?php echo $_COOKIE["comment"]; ?>" title="How, where and when did they WOW! you? (required)" /></textarea> </p> <h4>Your Details</h4> <p> <?php if (!isset($_COOKIE['name'])){ ?> <label for="name">Your Name (required)</label> <?php } ?> <input type="text" name="name" id="name" value="<?php echo readcookie('name'); ?>" title="Please tell us your name"/> </p> <p> <?php if (!isset($_COOKIE['email'])){ ?> <label for="email">Your Email (required)</label> <?php } ?> <input type="text" name="email" id="email" value="<?php echo readcookie('email'); ?>" title="Please enter your email address"/> </p> <p> <?php if (!isset($_COOKIE['phone'])){ ?> <label for="phone">Your Phone Number</label> <?php } ?> <input type="text" name="phone" id="phone" value="<?php echo readcookie('phone'); ?>" title="And your phone number"/> </p> <input class="button" type="submit" value="Send" /> </fieldset> </form> </div> <div id="footer"> </div> </body> </html> And here is the form processing script: Code: [Select] <?php include("functions.php"); checkaccess(0); require_once("includes/browser.php"); $browser = new Browser(); $thebrowser = ereg_replace("[^A-Za-z]", "", $browser->getBrowser()); $ver = $browser->getVersion(); setcookie("nominee",$_POST['nominee'],time()+3600); setcookie("comment",$_POST['comment'],time()+3600); setcookie("name",$_POST['name'],time()+3600); setcookie("email",$_POST['email'],time()+3600); setcookie("phone",$_POST['phone'],time()+3600); $email = $_POST['email']; if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $email_error="TRUE"; } if ($thebrowser.$ver != "InternetExplorer6.0") { /* if(!captcha() ) { header("location: nominate.php?err=Spam Protection Code"); } else*/ if($_POST['name']=="" || $_POST['name']=="Your Name (required)" || $_POST['nominee']=="Tell us who WOW!ed you today (required)" || $_POST['nominee']=="" || $_POST['comment']=="How, where and when did they WOW! you? (required)" || $_POST['comment']=="" || $_POST['email']=="" || $_POST['email']=="Your Email (required)" || $email_error=="TRUE" ) { header("location: mobile.php?err=Please complete the required fields"); } else { connect(); $name=format_text_for_database($_POST['name']); $email=format_text_for_database($_POST['email']); $phone=format_text_for_database($_POST['phone']); $nominee=format_text_for_database($_POST['nominee']); $jobtitle=format_text_for_database($_POST['jobtitle']); $department=format_text_for_database($_POST['department']); $comment=format_text_for_database($_POST['comment']); $type=format_text_for_database($_POST['type']); $cid=company; $mobile=format_text_for_database($_POST['mobile']); $sql=mysql_query("insert into comments (date, name, email, phone, department, nominee, jobtitle, comment, type, cid, mobile) values (now(), '$name', '$email', '$phone', '$department', '$nominee', '$jobtitle', '$comment', '$type', $cid, $mobile)"); $lastid=mysql_insert_id(); disconnect(); senduseremail($lastid); sendclientemail($lastid); header("location: mobile_thanks.php"); } } if ($thebrowser.$ver == "InternetExplorer6.0") { /* if(!captcha_spam() ) { header("location: nominate.php?err=Please re-enter the Spam Protection Code"); } else*/ if($_POST['name']=="" || $_POST['email']=="" || $_POST['comment']=="") { header("location: nominate.php?err=Please complete the required fields"); } else { connect(); $name=format_text_for_database($_POST['name']); $email=format_text_for_database($_POST['email']); $phone=format_text_for_database($_POST['phone']); $nominee=format_text_for_database($_POST['nominee']); $jobtitle=format_text_for_database($_POST['jobtitle']); $department=format_text_for_database($_POST['department']); $comment=format_text_for_database($_POST['comment']); $type=format_text_for_database($_POST['type']); $cid=company; $sql=mysql_query("insert into comments (date, name, email, phone, department, nominee, jobtitle, comment, type, cid) values (now(), '$name', '$email', '$phone', '$department', '$nominee', '$jobtitle', '$comment', '$type', $cid)"); $lastid=mysql_insert_id(); disconnect(); senduseremail($lastid); sendclientemail($lastid); header("location: mobile_thanks.php"); } } ?> Any pointers would be greatly appreciated. KN |