PHP - Form Snag
Hi Guys,
PHP has never been my fortay and I have hit a real snag. Please find below code for a simple PHP contact form. However, in the subject line of the email sent to me I would like it to show: Contact Form: $subject - ($subject is what is currently displayed). I know this is a simple fix however I have been messing about for hours and can't seem to get it right. Any help would be greatly appreciated. Best, Scott. Code: [Select] <?php define("WEBMASTER_EMAIL", 'contact@pearceresourcing.com'); error_reporting (E_ALL ^ E_NOTICE); ////////////////////////////////////////////////////// function ValidateEmail($email) { $regex = '/([a-z0-9_.-]+)'. # name '@'. # at '([a-z0-9.-]+){2,255}'. # domain & possibly subdomains '.'. # period '([a-z]+){2,10}/i'; # domain extension if($email == '') return false; else $eregi = preg_replace($regex, '', $email); return empty($eregi) ? true : false; } ////////////////////////////////////////////////////// $post = (!empty($_POST)) ? true : false; if($post) { $name = stripslashes($_POST['name']); $email = trim($_POST['email']); $subject = trim($_POST['subject']); $message = stripslashes($_POST['message']); $error = ''; // Check name if(!$name) $error .= 'Name required! '; // Check email if(!$email) $error .= 'E-mail required! '; if($email && !ValidateEmail($email)) $error .= 'E-mail address is not valid! '; // Check message if(!$message) $error .= "Please enter your message!"; if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) echo 'OK'; } else echo '<div class="errormsg">'.$error.'</div>'; } ?> Similar TutorialsGood evening all, I am trying to expand my experience with PHP by doing a small project for a personal website. I am working from scratch using notepad and so far have been having great sucess. My experience with C# is helping greatly but sadly ive hit a snag and can't seem to free myself. I have an array that is populated with items, and the prices for those items if you are buying/selling them. What I will have is a form with a drop list that is populated by this array list (already working) and a text entry that you can enter a numerical quantity value, then another drop list that will have buy / sell as an option. What the page will do is take the values from the form and calculate the "total" from the supplied values. Sadly some reason I cant set a $Variable to the value of the array values. I can echo them and get the correct value, but can't set the Variable to the arrays value! Code: [Select] <?php $ResBuySell = array( "Iron ingot" => array("Buy" => 6, "Sell" => 7), "Shadow iron ingot" => array("Buy" => 14, "Sell" => 16), "Dull copper ingot" => array("Buy" => 14, "Sell" => 16), "Copper ingot" => array("Buy" => 6, "Sell" => 7), "Bronze ingot" => array("Buy" => 6, "Sell" => 7), "Gold ingot" => array("Buy" => 6, "Sell" => 7), "Agapite ingot" => array("Buy" => 6, "Sell" => 7), "Verite ingot" => array("Buy" => 6, "Sell" => 7), "Valorite ingot" => array("Buy" => 6, "Sell" => 7), "Feathers" => array("Buy" => 6, "Sell" => 7), "Arrows" => array("Buy" => 6, "Sell" => 7), "Bolts" => array("Buy" => 6, "Sell" => 7), "Boards" => array("Buy" => 4, "Sell" => 6), "Spined leather" => array("Buy" => 16, "Sell" => 18), "Horned leather" => array("Buy" => 6, "Sell" => 7), "Barbed leather" => array("Buy" => 6, "Sell" => 7), "Cloth" => array("Buy" => 6, "Sell" => 7), "Ribs" => array("Buy" => 6, "Sell" => 7), "Fish steaks" => array("Buy" => 6, "Sell" => 7), "Orange petals" => array("Buy" => 6, "Sell" => 7), "Red leaves" => array("Buy" => 6, "Sell" => 7), "Green thorns" => array("Buy" => 6, "Sell" => 7) ); function GetPrice($ResType = "Iron ingot", $TranType = "Buy") { return $ResBuySell[$ResType][$ResType]; } function GetQuantity() { return 5; } function GetTotal() { $ResPrice = GetPrice(); $ResQuanity = GetQuantity(); $ResTotal = $ResPrice * $ResQuanity; return $ResTotal; } echo GetTotal(); ?> Quote 0 The problem resides he Code: [Select] function GetPrice($ResType = "Iron ingot", $TranType = "Buy") { return $ResBuySell[$ResType][$ResType]; } Some reason when I echo this: Code: [Select] $ResType = "Iron ingot"; $TranType = "Buy"; echo $ResBuySell[$ResType][$ResType]; it will return; Quote 6 The proper value, but when I put it into a function and try to retrieve this info via the function it returns zero. I am a beginner with php and just trying to learn by trial and error, but after failing at this for 5 days I figured it was time to call in help from the big guns! Thanks in advance to anyone who can offer my any assistance with this problem! Hello, I have coded a contact form in PHP and I want to know, if according to you, it is secure! I am new in PHP, so I want some feedback from you. Moreover, I have also two problems based on the contact form. It is a bit complicated to explain, thus, I will break each of my problem one by one. FIRST:The first thing I want to know, is if my contact form secure according to you: The HTML with the PHP codes: Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Assigning variables to elements $first = htmlentities($_POST['first']); $last = htmlentities($_POST['last']); $sub = htmlentities($_POST['subject']); $email = htmlentities($_POST['email']); $web = htmlentities($_POST['website']); $heard = htmlentities($_POST['heard']); $comment = htmlentities($_POST['message']); $cap = htmlentities($_POST['captcha']); //Declaring the email address with body content $to = 'alithebestofall2010@gmail.com'; $body ="First name: '$first' \n\n Last name: '$last' \n\n Subject: '$sub' \n\n Email: '$email' \n\n Website: '$web' \n\n Heard from us: '$heard' \n\n Comments: '$comment'"; //Validate the forms if (empty($first) || empty($last) || empty($sub) || empty($email) || empty($comment) || empty($cap)) { echo '<p class="error">Required fields must be filled!</p>'; header ('refresh= 3; url= index.php'); return false; } elseif (filter_var($first, FILTER_VALIDATE_INT) || filter_var($last, FILTER_VALIDATE_INT)) { echo '<p class="error">You cannot enter a number as either the first or last name!</p>'; return false; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '<p class="error">Incorrect email address!</p>'; return false; } elseif (!($cap === '12')){ echo '<p class="error">Invalid captcha, try again!</p>'; return false; } else { mail ($to, $sub, $body); echo '<p class="success">Thank you for contacting us!</p>'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p>Your first name: <span class="required">*</span></p> <p><input type="text" name="first" size="40" placeholder="Ex: Paul"/></p> <p>Your last name: <span class="required">*</span></p> <p><input type="text" name="last" size="40" placeholder="Ex: Smith"/></p> <p>Subject: <span class="required">*</span></p> <p><input type="text" name="subject" size="40" placeholder="Ex: Contact"/></p> <p>Your email address: <span class="required">*</span></p> <p><input type="text" name="email" size="40" placeholder="Ex: example@xxx.com"/></p> <p>Website:</p> <p><input type="text" name="website" size="40" placeholder="Ex: http//:google.com"/></p> <p>Where you have heard us?: <span class="required">*</span></p> <p><select name="heard"> <option>Internet</option> <option>Newspapers</option> <option>Friends or relatives</option> <option>Others</option> </select></p> <p>Your message: <span class="required">*</span></p> <p><textarea cols="75" rows="20" name="message"></textarea></p> <p>Are you human? Sum this please: 5 + 7 = ?: <span class="required">*</span></p></p> <p><input type="text" name="captcha" size="10"/></p> <p><input type="submit" name="submit" value="Send" class="button"/> <input type="reset" value="Reset" class="button"/></p> </form> SECOND PROBLEM:If a user has made a mistake, he gets the error message so that he can correct! However, when a mistake in the form occurs, all the data the user has entered are disappeared! I want the data to keep appearing so that the user does not start over again to fill the form. THIRD: When the erro message is displayed to notify the user that he made a mistake when submitting the form, the message is displaying on the top of the page. I want it to appear below each respective field. How to do that? In JQuery it is simple, but in PHP, I am confusing! Hello, first time poster.. I've looked the web over for a long time and can't figure this one out. - Below is basic code that successfully checks MySQL for a match and displays result. I was debugging and forced the "height" and "width" to be 24 and 36 to make sure that wasn't the problem. That's good.. - I'd like to give the user ability to select width and height from a form.. and have it do an onchange this.form.submit so the form can be changing as fields are altered (thus the onchange interaction) - In a normal coding environment I've done this numerous times with no "Page cannot be displayed" problems. It would simply change one select-option value at a time til they get down the form and click submit... but in WordPress I'm having trouble making even ONE single onchange work! - I've implemented the plugins they offer which allows you to "copy+paste" your php code directly into their wysiwyg editor. That works with basic tests like my first bullet point above. - I've copied and pasted the wordpress url (including the little ?page_id=123) into the form "action" url... that didn't work... tried forcing it into an <option value=""> tag.. didn't work. I'm just not sure. I've obviously put xx's in place of private info.. Why does this form give me Page Cannot Be Displayed in WordPress every time? It won't do anything no matter how simple.. using onchange.. Code.. $con = mysql_connect("xxxx.xxxxxxx.com","xxxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxx", $con); $myprodwidth=24; $myprodheight=36; $result = mysql_query("SELECT * FROM product_sizes WHERE prodwidth='$myprodwidth' and prodheight='$myprodheight'"); while($row = mysql_fetch_array($result)) { echo $row['prodprice']; } mysql_close($con); <form method="post" action=""> <select name="myheight" onchange="this.form.submit();"> <option selected="selected" value="">select height</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">36</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">48</option> </select> I have read around and can't seem to find the right coding for what I need on this forum and some other other forums. I have a contact form (as listed below) and I need 2 locations (Print Name and Title) fields to auto-populate on a separate form (can be a doc, pdf, etc. any form of document which is easiest) and this form can be totally back end and the individual using the form never is going to see the form. It's going on a contract form, that we would like to auto-populate. Also is there a simple attachment code so individuals can attach documents to the code? <p style: align="center"><form action="mailtest.php" method="POST"> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> <div align="center"> <p class="style1">Name</p> <input type="text" name="name"> <p class="style1">Address</p> <input type="text" name="address"> <p class="style1">Email</p> <input type="text" name="email"> <p class="style1">Phone</p> <input type="text" name="phone"> <p class="style1">Debtor</p> <input type="text" name="debtor"> <p class="style1">Debtor Address</p> <input type="text" name="debtora"> <br /> <br /> <a href="authoforms.php" target="_blank" style="color:#ffcb00" vlink="#ffcb00">Click here to view Assignment Agreement and Contract Agreement</a> <p class="style1"><input type='checkbox' name='chk' value='I Have read and Agree to the terms.'> I have read and agree to the Assignment and Contract Agreement <br></p> <p class="style1">Print Name</p> <input type="text" name="pname"> <p class="style1">Title</p> <input type="text" name="title"> <p class="style1">I hear by agree that the information I have provided is true, accurate and the information I am submitting is <br /> not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms:</p> <select name="agree" size="1"> <option value="Agree">Agree</option> <option value="Disagree">Disagree</option> </select> <br /> <br /> <p class="style1">Employee ID:</p> <input type="text" name="employee"> <br /> <input type="submit" value="Send"><input type="reset" value="Clear"> </div> </form> </p> The mailtest php is this ?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $name = $_POST['name']; $address = $_POST['address']; $email = $_POST['email']; $phone = $_POST['phone']; $debtor = $_POST['debtor']; $debtora = $_POST['debtora']; $value = $_POST['chk']; $pname = $_POST['pname']; $title = $_POST['title']; $agree = $_POST['agree']; $employee = $_POST['employee']; $formcontent=" From: $name \n Address: $address \n Email: $email \n Phone: $phone \n Debtor: $debtor \n Debtor's Address: $debtora \n 'Client' has read Assignment and Contract Agreement: $value \n Print Name: $pname \n Title: $title \n I hear by agree that the information I have provided is true, accurate and the information I am submitting is not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms: $agree \n \n Employee ID: $employee \n IP: $ip"; $recipient = "mail@crapower.com"; $subject = "Online Authorization Form 33.3%"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!" . " -" . "<a href='index.php' style='text-decoration:none;color:#ffcb00;'> Return Home</a>"; $ip = $_POST['visitoraddress'] ?> Stumped! I have a client who has a form where they upload files to their server: title, two password fields, and the file
They have been unable to upload anything over 10m
Small (under 10mb) files work.
Larger doesn’t
I’ve tracked it down, I think, that the processing page appears to be dropping the form values when the file takes a bit to upload.
I echo’ed the values that are grabbed from the form, and they return empty strings if it takes a while for the file to upload (a large file) - they pass fine if the file is smaller.
I think I've got the php info set correctly, but cannot for the life of me figure out how to adjust the timing out issue, or even where to troubleshoot.
Here's my phpinfo:
Max Requests
Per Child: 750 - Keep Alive: off - Max Per Connection: 100
Timeouts
Connection: 120 - Keep-Alive: 5
Directive
Local Value
Master Value
allow_call_time_pass_reference
Off
Off
allow_url_fopen
On
On
allow_url_include
Off
Off
always_populate_raw_post_data
Off
Off
arg_separator.input
&
&
arg_separator.output
&
&
asp_tags
Off
Off
auto_append_file
no value
no value
auto_globals_jit
On
On
auto_prepend_file
no value
no value
browscap
/etc/browscap.ini
/etc/browscap.ini
default_charset
no value
no value
default_mimetype
text/html
text/html
define_syslog_variables
Off
Off
disable_classes
no value
no value
disable_functions
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
display_errors
Off
Off
display_startup_errors
Off
Off
doc_root
no value
no value
docref_ext
no value
no value
docref_root
no value
no value
enable_dl
Off
Off
error_append_string
no value
no value
error_log
/mnt/Target01/337846/945285/www.dermerrealestate.com/logs/php_errors.log
no value
error_prepend_string
no value
no value
error_reporting
30711
30711
exit_on_timeout
Off
Off
expose_php
Off
Off
extension_dir
/usr/lib64/php/modules
/usr/lib64/php/modules
file_uploads
On
On
highlight.bg
#FFFFFF
#FFFFFF
highlight.comment
#FF8000
#FF8000
highlight.default
#0000BB
#0000BB
highlight.html
#000000
#000000
highlight.keyword
#007700
#007700
highlight.string
#DD0000
#DD0000
html_errors
On
On
ignore_repeated_errors
Off
Off
ignore_repeated_source
Off
Off
ignore_user_abort
Off
Off
implicit_flush
Off
Off
include_path
.:/usr/share/pear:/usr/share/php
.:/usr/share/pear:/usr/share/php
log_errors
On
On
log_errors_max_len
1024
1024
magic_quotes_gpc
On
On
magic_quotes_runtime
Off
Off
magic_quotes_sybase
Off
Off
mail.add_x_header
On
On
mail.force_extra_parameters
no value
no value
mail.log
no value
no value
max_execution_time
30
30
max_file_uploads
20
20
max_input_nesting_level
64
64
max_input_time
60
60
max_input_vars
1000
1000
memory_limit
128M
128M
open_basedir
no value
no value
output_buffering
no value
no value
output_handler
no value
no value
post_max_size
8M
8M
precision
14
14
realpath_cache_size
4M
4M
realpath_cache_ttl
120
120
register_argc_argv
On
On
register_globals
Off
Off
register_long_arrays
On
On
report_memleaks
On
On
report_zend_debug
On
On
request_order
no value
no value
safe_mode
Off
Off
safe_mode_exec_dir
no value
no value
safe_mode_gid
Off
Off
safe_mode_include_dir
no value
no value
sendmail_from
no value
no value
sendmail_path
/usr/sbin/sendmail -t -i
/usr/sbin/sendmail -t -i
serialize_precision
100
100
short_open_tag
On
On
SMTP
localhost
localhost
smtp_port
25
25
sql.safe_mode
Off
Off
track_errors
Off
Off
unserialize_callback_func
no value
no value
upload_max_filesize
8M
8M
upload_tmp_dir
/tmp
/tmp
user_dir
no value
no value
user_ini.cache_ttl
300
300
user_ini.filename
.user.ini
.user.ini
variables_order
EGPCS
EGPCS
xmlrpc_error_number
0
0
xmlrpc_errors
Off
Off
y2k_compliance
On
On
zend.enable_gc
On
On
There are two pieces to this- The HTML Form and the resulting php. I can't seem to make the leap, from the code to having the form produce the php page so others can view it until the form is again submitted overwriting the php, thus generating new content. The environment I am working in is limited to IIs 5.1 and php 5.2.17 without mySQL or other DB I'm new to php, this isn't homework,or commercialization, it's for children. I am thinking perhaps fwrite / fread but can't get my head around it. Code snipets below. Any help, please use portions of this code in hopes I can understand it Thanks Code snipet from Output.php Code: [Select] <?php $t1image = $_POST["t1image"]; $t1title = $_POST["t1title"]; $t1info = $_POST["t1info"]; $t2image = $_POST["t2image"]; $t2title = $_POST["t2title"]; $t2info = $_POST["t2info"]; ?> ... <tbody> <tr><!--Headers--> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Animal</td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Image thumb<br> </td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Date<br> </td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Information<br> </td> </tr> <tr> <td style="vertical-align: top; text-align: center;">Monkey </td> <td style="vertical-align: top; text-align: center;"><img src="<?php echo $t1image.'.gif'; ?>"><!--single image presented selected from radio buttons--> </td> <td style="vertical-align: top; text-align: center;"><?php echo date("m/d/Yh:i A"); ?><!--time stamp generated when submitted form populates all fields at once--> </td> <td style="vertical-align: top; text-align: center;"><a href="#monkey" rel="facebox"><?php echo $t1title ?></a><!--Link name provided by "Title 1", that links to hidden Div generated page with content from "Info1" field--> <div id="Monkey" style="display:none"> <?php echo $t1info; ?> </div> </td> </tr> <tr> <td style="vertical-align: top; text-align: center;">Cat<br> </td> <td style="vertical-align: top; text-align: center;"><img src="<?php echo $t2image.'.gif'?>"></td> <td style="vertical-align: top; text-align: center;"><?php echo date("m/d/Yh:i A"); ?></td> <td style="vertical-align: top; text-align: center;"><a href="#Cat" rel="facebox"><?php echo $t2title ?></a> <div id="Cat" style="display:none"> <?php echo $t2info; ?> </div> </td> </tr> <tr> This replicates several times down the page around 15-20 times ( t1### - t20###) Code Snipet from HTML Form Code: [Select] <form action="animals.php" method="post"> <div style="text-align: left;"><big style="font-family: Garamond; font-weight: bold; color: rgb(51, 51, 255);"><big><big><span>Monkey</span></big></big></big><br> <table style="text-align: left; width: 110px;" border="0" cellpadding="2" cellspacing="0"> <tbody><tr> <td style="vertical-align: top;">Image thumb<br> <input type="radio" name="t1image" value="No opinion" checked><img src="eh.gif" alt="Eh"> <input type="radio" name="t1image" value="Ok"><img src="ok.gif" alt="ok"> <input type="radio" name="t1image" value="Like"><img src="like.gif" alt="Like"> <input type="radio" name="t1image" value="Dont"><img src="dont.gif" alt="Don't Like"> <input type="radio" name="t1image" value="Hate"><img src="hate.gif" alt="Hate"> <input type="radio" name="t1image" value="Other"><img src="other.gif" alt="Other"> <br> Why Title:<input type="text" name="t1title" size="45" value="..."/></td> <td style="vertical-align: top;"> Explain:<br> <textarea name="t1info" cols=45 rows=3 value="..."></textarea> </td></tr></table> <br> <!--Next--> How do I get the Form data to save to the php page for others to view? Hi i am trying to change the query to sort by desc or asc I am using the switch method but the form is not calling the switch statment can someone help me out please? this is the swicth script Code: [Select] switch ($sortby) { case "ASC": $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'orderby' => 'title', 'order' => 'ASC', 'paged' => get_query_var('paged') ); break; case "DESC": $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'orderby' => 'title', 'order' => 'DESC', 'paged' => get_query_var('paged') ); break; }This is the form Code: [Select] <form name="myForm"> <select id="sortby" > <option value="ASC">ASC</option> <option value="DESC">DESC</option> </select> </form> I intend to use a onchange so that when depending on the option they select it will change the order? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347360.0 I'm not sure why, but once I added a search form in my nav menu, it made my other forms on the website such as login and signup form take them to where the search button would take them. any ideas??? Hi- the code below lets me upload a CSV file to my database if I have 1 field in my database and 1 column in my CSV. I need to add to my db "player_id" from the CVS file and "event_name" and "event_type" from the form... any ideas??? here's the code: Code: [Select] <?php $hoststring =""; $database = ""; $username = ""; $password = ""; $makeconnection = mysql_pconnect($hoststring, $username, $password); ?> <?php ob_start(); mysql_select_db($database, $makeconnection); $sql_get_players=" SELECT * FROM tabel ORDER BY player_id ASC"; // $get_players = mysql_query($sql_get_players, $makeconnection) or die(mysql_error()); $row_get_players = mysql_fetch_assoc($get_players); // $message = null; $allowed_extensions = array('csv'); $upload_path = '.'; //same directory if (!empty($_FILES['file'])) { if ($_FILES['file']['error'] == 0) { // check extension $file = explode(".", $_FILES['file']['name']); $extension = array_pop($file); if (in_array($extension, $allowed_extensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'], $upload_path.'/'.$_FILES['file']['name'])) { if (($handle = fopen($upload_path.'/'.$_FILES['file']['name'], "r")) !== false) { $keys = array(); $out = array(); $insert = array(); $line = 1; while (($row = fgetcsv($handle, 0, ',', '"')) !== FALSE) { foreach($row as $key => $value) { if ($line === 1) { $keys[$key] = $value; } else { $out[$line][$key] = $value; } } $line++; } fclose($handle); if (!empty($keys) && !empty($out)) { $db = new PDO( 'mysql:host=host;dbname=db', 'user', 'pw'); $db->exec("SET CHARACTER SET utf8"); foreach($out as $key => $value) { $sql = "INSERT INTO `table` (`"; $sql .= implode("`player_id`", $keys); $sql .= "`) VALUES ("; $sql .= implode(", ", array_fill(0, count($keys), "?")); $sql .= ")"; $statement = $db->prepare($sql); $statement->execute($value); } $message = '<span>File has been uploaded successfully</span>'; } } } } else { $message = '<span>Only .csv file format is allowed</span>'; } } else { $message = '<span>There was a problem with your file</span>'; } } ob_flush();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>CSV File Upload</title> </head> <body> <form class="form" action="" method="post" enctype="multipart/form-data"> <h3>Select Your File</h3> <p><?php echo $message; ?></p> <input type="file" name="file" id="file" size="30" /> <br/> <label>Event Name:</label><input name="event_name" type="text" value="" /> <br/> <label>Event Type:</label><input name="event_type" type="text" value="" /> <br/> <input type="submit" id="btn" class="button" value="Submit" /> </form> <br/> <h3>Results:</h3> <?php do { ?> <p><?php echo $row_get_players['player_id'];?></p> <?php } while ($row_get_players = mysql_fetch_assoc($get_players)); ?> </body> </html> Hi all, What I am trying to achieve is, I thought quite simple! Basically, a user signs up and chooses a package, form is submitted, details added to the database, email sent to customer, then I want to direct them to a paypal payment screen, this is where I am having issues! Is their any way in php to submit a form without user interaction? Here is my code for the form process page Code: [Select] <?php include('config.php'); require('scripts/class.phpmailer.php'); $package = $_POST['select1']; $name = $_POST['name']; $email = $_POST['email']; $password = md5($_POST['password']); $domain = $_POST['domain']; $a_username = $_POST['a_username']; $a_password = $_POST['a_password']; $query=mysql_query("INSERT INTO orders (package, name, email, password, domain, a_username, a_password) VALUES ('$package', '$name', '$email', '$password', '$domain', '$a_username', '$a_password')"); if (!$query) { echo "fail<br>"; echo mysql_error(); } else { $id = mysql_insert_id(); $query1=mysql_query("INSERT INTO customers (id, name, email, password) values ('$id', '$name', '$email', '$password')"); if (!$query1) { echo "fail<br>"; echo mysql_error(); } if($package=="Reseller Hosting") { //email stuff here - all works - just cutting it to keep the code short if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type="hidden" name="business" value="subscription@jollyhosting.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="item_name" value="Jolly Hosting Reseller Packages"> <input type="hidden" name="no_shipping" value="1"> <!--1st month --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="3.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="src" value="1"> <input type="hidden" name="sra" value="1"> </form>'; <?php } //last } //end ?> Which one is better for standards practices in PHP. 1. Using the same form for everything. (Add and edit). Meaning setting up one form to handle adding new records, as well as editing existing records. Or 2. Using two different forms for both actions. Use one form/area to handle Adding, and one form/area to handle editing. Which one of these are better from a standards/practice point of a view. Which one better fits into the MVC platform (a framework like Codeignitor, or Cake). Should their be separate controller functions/views for add and edit or should they all be in the same controller function/form. Thanks for the feedback. Is jquery/Ajax better than real/raw PHP for form validation ?! What if JavaScript is turned off on the browser?! why after someone refreshing a page on the browser, the variables used to echo error after invalid data is being submitted will return the undefined variables error?! And how to handle form validation including an empty form field, maximum amount of value entered and so on Hi, how can i create a form within a form with the click of a button? so that when i click add new item, it brings form fields under the current one. hope my explanation helps thanks Code: [Select] <form id="form1" name="form1" method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="22%">Invoice Number </td> <td width="78%"> </td> </tr> <tr> <td>Date Issued </td> <td> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="10%">Quantity</td> <td width="70%">Description</td> <td width="9%">Taxable</td> <td width="11%">Amnount</td> </tr> <tr> <td valign="top"><input name="textfield" type="text" size="7" /></td> <td valign="top"><textarea name="textfield2" cols="80"></textarea></td> <td valign="top"><input type="checkbox" name="checkbox" value="checkbox" /></td> <td valign="top"><input name="textfield3" type="text" size="12" /></td> </tr> <tr> <td colspan="4"><input type="submit" name="Submit" value="Add New Item" /></td> </tr> </table></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form> As the topis says, I need help with an email form. You must have valid email address to go further, so lets say you write asdada as email, you won't be able to register the account, you must have asdada@hotmai.com or something like that. If anyone knows it would be awesome! This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=326600.0 I have a form on our website that a user can fill out for custom product. I want the form data to be 1) stored into a mysql database AND after storing said data, 2) email the same data to our sales department. 1) The form data DOES get stored into mysql database (except for the first two fields, for some weird reason) 2) I added a "mail" section to the php file that stores the data into the database, but it is not working correctly. I have stripped the email portion down to sending just one of the fields in the "message" to make it easier for troubleshooting I have included here, both the form section of the html file, and the formdata.php file that processes the data for your analysis. I am relatively new to php so there are going to be some issues with security, but I can work on those after I get the store & email process to work correctly. Please review my code and see if anyone can be of assistance. I looked through the forums and couldn't find another issue that was the same as mine. If I just overlooked, please tell me the thread post #. Thanks THE FORM WHICH COLLECTS THE DATA ******************************* <form method=POST action=formdata.php> <table width="640" border=0 align="center"> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=FName size=25></td> <td><div align="right"><b>Telephone</b></div></td> <td><input type=text name=Tel size=25></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=LName size=25></td> <td><div align="right"><b>Fax</b></div></td> <td><input type=text name=Fax size=25></td> </tr> <tr> <td align=right><b>Title</b></td> <td><input type=text name=Title size=25></td> <td><div align="right"><b>Email</b></div></td> <td><input type=text name=Email size=50></td> </tr> <tr> <td align=right><b>Company</b></td> <td><input type=text name=Comp size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Address</b></td> <td><input type=text name=Addr size=25></td> <td><div align="right"><b>Estimated Annual Volume</b></div></td> <td><input type=text name=EAV size=25></td> </tr> <tr> <td align=right><b>City</b></td> <td><input type=text name=City size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>State/Province</b></td> <td><input type=text name=SProv size=25></td> <td><div align="right"><b>Application</b></div></td> <td><input type=text name=Appl size=25></td> </tr> <tr> <td align=right><b>Country</b></td> <td><input type=text name=Ctry size=25></td> <td><div align="right"><b>Type of System</b></div></td> <td><input type=text name=Syst size=25></td> </tr> <tr> <td align=right><b>Zip/Postal Code</b></td> <td><input type=text name=ZPC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td><div align="right"><strong><font color="#FFFF00" face="Arial, Helvetica, sans-serif">COIL DESIGN</font></strong></div></td> <td><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PARAMETERS</strong></font></td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Primary Resistance (ohms)</b></td> <td><input type=text name=Pres size=25></td> <td><div align="right"><b>Primary Inductance (mH)</b></div></td> <td><input type=text name=Pind size=25></td> </tr> <tr> <td align=right><b>Secondary Resistance (ohms)</b></td> <td><input type=text name=Sres size=25></td> <td><div align="right"><b>Secondary Inductance (H)</b></div></td> <td><input type=text name=Sind size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Peak Operating Current (Amps)</b></td> <td><input type=text name=POC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Output Energy (mJ)</b></td> <td><input type=text name=Egy size=25></td> <td><div align="right"><b>Output Voltage (kV)</b></div></td> <td><input type=text name=Volt size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b># HV Towers per Coil</b></td> <td><input type=text name=TPC size=25></td> <td><div align="right"><b># of Coils per Package</b></div></td> <td><input type=text name=CPP size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <th colspan=4><b>Please enter any additional information he </b></th> </tr> <tr> <th colspan=4><textarea name=Mess cols=50 rows=10 id="Message"></textarea></th> </tr> </table> </dl> <div align="center"> <p> <input type=hidden name=BodyTag value="<body bgcolor="#484589" text="#FFFFFF" link="#FFFF00" alink="#FFFFFF" vlink="#FF7F00">"> <input type=hidden name=FA value=SendMail> </p> <p><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PLEASE MAKE SURE ALL INFORMATION<br> IS CORRECT BEFORE SUBMITTING</strong></font></p> <p> <input type=submit value="Submit Form"> </p> </div> </form> THE FILE THAT PROCESSES THE FORM DATA (formdata.php) *********************************************** <?php $con = mysql_connect("localhost","XXX","XXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("customform", $con); $sql="INSERT INTO formdata (Fname, Lname, Title, Comp, Addr, City, SProv, Ctry, ZPC, Tel, Fax, Email, EAV, Appl, Syst, Pres, Pind, Sres, Sind, POC, Egy, Volt, TPC, CPP, Mess) VALUES ('$_POST[Fname]','$_POST[Lname]','$_POST[Title]','$_POST[Comp]','$_POST[Addr]','$_POST[City]','$_POST[SProv]','$_POST[Ctry]','$_POST[ZPC]','$_POST[Tel]','$_POST[Fax]','$_POST[Email]','$_POST[EAV]','$_POST[Appl]','$_POST[Syst]','$_POST[Pres]','$_POST[Pind]','$_POST[Sres]','$_POST[Sind]','$_POST[POC]','$_POST[Egy]','$_POST[Volt]','$_POST[TPC]','$_POST[CPP]','$_POST[Mess]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Your Information Was Successfully Posted"; mysql_close($con); $to = "recipient email address here"; $subject = "Custom Form"; $email = $_POST['Email'] ; $message = $_POST['Comp'] ; $headers = "From: $Email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?> Hi guys, as shown in the code I have a form running in another form, the first form submits to updateprofile.php but within that I have got another submit button and another form which should submit to updatepassword.php, but when I click the button which should take the action to updatepassword.php it still takes me through to updateprofile.php, so for some reason the 2nd form is not recognizable? any help here? Code: [Select] <?php include "connect.php"; echo '<p><a href="index.php">Home</a></p>'; if(isset($_SESSION['email'])) $email = $_SESSION['email']; { $result = mysql_query("SELECT id, email, firstname, lastname, website, address1, address2, city, postcode, phone, county, dobmonth, dobday, dobyear, Sex, Level, services, philosophy, mission, customerpromises, coursesundertaken, othercourses, nongolfcert, crbcheck, firstaid, latestcpd, cpdgoals, mostinfluential, mainstrength, yeargolfexperience, customerfeedback, wgtffeedback FROM member WHERE email = '$email'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { ?> <link rel="stylesheet" type="text/css" href="view.css" media="all"> <script type="text/javascript" src="view.js"></script> <form onsubmit='return formValidator()' id='register' action='updateprofile.php' method='post' accept-charset='UTF-8'> <body id="main_body" > <img id="top" src="top.png" alt=""> <div id="form_container"> <h1>Add a Member</h1> <form id="form_362567" class="appnitro" method="post" action=""> <div class="form_description"> <h2> My Profile</h2> <p></p> </div> <ul > <li class="section_break"> <h3>Login Details</h3> <p></p> </li> <li id="li_2" > <label class="description" for="email">Email: </label> <div> <input id="email" name="email" class="element text medium" type="text" maxlength="255" value="<?php echo $row['email']; ?>"/> </div> </li> <form onsubmit='' id='update' action='updatepassword.php' method='post' accept-charset='UTF-8'> <li id="li_3" > <label class="description" for="password">Old Password </label> <div> <input id="oldpassword" name="oldpassword" class="element text medium" type="password" maxlength="255" value=""/> </div> </li> <li id="li_4" > <label class="description" for="confirmpw">New Password: (Must be between 6-50 characters) </label> <div> <input id="newpassword" name="newpassword" class="element text medium" type="text" maxlength="255" value=""/> </div> </li> <li id="li_4" > <label class="description" for="confirmpw">Confirm New Password: </label> <div> <input id="confirmnewpassword" name="confirmnewpassword" class="element text medium" type="text" maxlength="255" value=""/> <br><input type='submit' name='Submit' value='Update Password' /> </div> </form> </li><li class="section_break"> <h3>Personal Details</h3> <p></p> </li> <li id="li_6" > <label class="description" for="element_6">Name: </label> <span> <input id="firstname" name= "firstname" class="element text" maxlength="255" size="8" value="<?php echo $row['firstname']; ?>"/> <label>First</label> </span> <span> <input id="lastname" name= "lastname" class="element text" maxlength="255" size="14" value="<?php echo $row['lastname']; ?>"/> <label>Last</label> </span> </li> <li id="li_7" > <label class="description" for="website">Web Site: </label> <div> <input id="website" name="website" class="element text medium" type="text" maxlength="255" value="<?php echo $row['website']; ?>"/> </div> </li> <li id="li_12" > </li> <li id="li_11" > <label class="description" for="element_11">Contact Details </label> <div> <input id="address1" name="address1" class="element text large" value="<?php echo $row['address1']; ?>" type="text"> <label for="element_11_1">Street Address</label> </div> <div> <input id="address2" name="address2" class="element text large" value="<?php echo $row['address2']; ?>" type="text"> <label for="element_11_2">Address Line 2</label> </div> <div class="left"> <input id="city" name="city" class="element text medium" value="<?php echo $row['city']; ?>" type="text"> <label for="element_11_3">City</label> </div> <div class="right"> <input id="phone" name="phone" class="element text medium" value="<?php echo $row['phone']; ?>" type="text"> <label for="element_11_4">Phone Number</label> </div> <div class="left"> <input id="postcode" name="postcode" class="element text medium" maxlength="15" value="<?php echo $row['postcode']; ?>" type="text"> <label for="element_11_5">Postcode</label> </div> <div class="right"> <select class="element select medium" id="county" name="county"> <option value="<?php echo $row['county']; ?>" selected="selected"><?php echo $row['county']; ?></option> <optgroup label="England"> <option>Bedfordshire</option> <option>Berkshire</option> <option>Bristol</option> <option>Buckinghamshire</option> <option>Cambridgeshire</option> <option>Cheshire</option> <option>City of London</option> <option>Cornwall</option> <option>Cumbria</option> <option>Derbyshire</option> <option>Devon</option> <option>Dorset</option> <option>Durham</option> <option>East Riding of Yorkshire</option> <option>East Sussex</option> <option>Essex</option> <option>Gloucestershire</option> <option>Greater London</option> <option>Greater Manchester</option> <option>Hampshire</option> <option>Herefordshire</option> <option>Hertfordshire</option> <option>Isle of Wight</option> <option>Kent</option> <option>Lancashire</option> <option>Leicestershire</option> <option>Lincolnshire</option> <option>Merseyside</option> <option>Norfolk</option> <option>North Yorkshire</option> <option>Northamptonshire</option> <option>Northumberland</option> <option>Nottinghamshire</option> <option>Oxfordshire</option> <option>Rutland</option> <option>Shropshire</option> <option>Somerset</option> <option>South Yorkshire</option> <option>Staffordshire</option> <option>Suffolk</option> <option>Surrey</option> <option>Tyne and Wear</option> <option>Warwickshire</option> <option>West Midlands</option> <option>West Sussex</option> <option>West Yorkshire</option> <option>Wiltshire</option> <option>Worcestershire</option> </optgroup> <optgroup label="Wales"> <option>Anglesey</option> <option>Brecknockshire</option> <option>Caernarfonshire</option> <option>Carmarthenshire</option> <option>Cardiganshire</option> <option>Denbighshire</option> <option>Flintshire</option> <option>Glamorgan</option> <option>Merioneth</option> <option>Monmouthshire</option> <option>Montgomeryshire</option> <option>Pembrokeshire</option> <option>Radnorshire</option> </optgroup> <optgroup label="Scotland"> <option>Aberdeenshire</option> <option>Angus</option> <option>Argyllshire</option> <option>Ayrshire</option> <option>Banffshire</option> <option>Berwickshire</option> <option>Buteshire</option> <option>Cromartyshire</option> <option>Caithness</option> <option>Clackmannanshire</option> <option>Dumfriesshire</option> <option>Dunbartonshire</option> <option>East Lothian</option> <option>Fife</option> <option>Inverness-shire</option> <option>Kincardineshire</option> <option>Kinross</option> <option>Kirkcudbrightshire</option> <option>Lanarkshire</option> <option>Midlothian</option> <option>Morayshire</option> <option>Nairnshire</option> <option>Orkney</option> <option>Peeblesshire</option> <option>Perthshire</option> <option>Renfrewshire</option> <option>Ross-shire</option> <option>Roxburghshire</option> <option>Selkirkshire</option> <option>Shetland</option> <option>Stirlingshire</option> <option>Sutherland</option> <option>West Lothian</option> <option>Wigtownshire</option> </optgroup> <optgroup label="Northern Ireland"> <option>Antrim</option> <option>Armagh</option> <option>Down</option> <option>Fermanagh</option> <option>Londonderry</option> <option>Tyrone</option> </optgroup> </select> <label for="element_11_6">County</label> </div> <br> <label for='dob' class="element text medium" >Date of Birth:</label><br> <select name="dobmonth" id="dobmonth"> <option value="<?php echo $row['dobmonth']; ?>" selected="selected"><?php echo $row['dobmonth']; ?></option> <option value="January">January</option> <option value="Febuary">Febuary</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <select name="dobday" id="dobday"> <option value="<?php echo $row['dobday']; ?>" selected="selected"><?php echo $row['dobday']; ?></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="dobyear" id="dobyear"> <option value="<?php echo $row['dobyear']; ?>" selected="selected"><?php echo $row['dobyear']; ?></option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> <option value="1973">1973</option> <option value="1972">1972</option> <option value="1971">1971</option> <option value="1970">1970</option> <option value="1969">1969</option> <option value="1968">1968</option> <option value="1967">1967</option> <option value="1966">1966</option> <option value="1965">1965</option> <option value="1964">1964</option> <option value="1963">1963</option> <option value="1962">1962</option> <option value="1961">1961</option> <option value="1960">1960</option> <option value="1959">1959</option> <option value="1958">1958</option> <option value="1957">1957</option> <option value="1956">1956</option> <option value="1955">1955</option> <option value="1954">1954</option> <option value="1953">1953</option> <option value="1952">1952</option> <option value="1951">1951</option> <option value="1950">1950</option> <option value="1949">1949</option> <option value="1948">1948</option> <option value="1947">1947</option> <option value="1946">1946</option> <option value="1945">1945</option> <option value="1944">1944</option> <option value="1943">1943</option> <option value="1942">1942</option> <option value="1941">1941</option> <option value="1940">1940</option> <option value="1939">1939</option> <option value="1938">1938</option> <option value="1937">1937</option> <option value="1936">1936</option> <option value="1935">1935</option> <option value="1934">1934</option> <option value="1933">1933</option> <option value="1932">1932</option> <option value="1931">1931</option> <option value="1930">1930</option> <option value="1929">1929</option> <option value="1928">1928</option> <option value="1927">1927</option> <option value="1926">1926</option> <option value="1925">1925</option> <option value="1924">1924</option> <option value="1923">1923</option> <option value="1922">1922</option> <option value="1921">1921</option> <option value="1920">1920</option> <option value="1919">1919</option> <option value="1918">1918</option> <option value="1917">1917</option> <option value="1916">1916</option> <option value="1915">1915</option> <option value="1914">1914</option> <option value="1913">1913</option> <option value="1912">1912</option> <option value="1911">1911</option> <option value="1910">1910</option> <option value="1909">1909</option> <option value="1908">1908</option> <option value="1907">1907</option> <option value="1906">1906</option> <option value="1905">1905</option> <option value="1904">1904</option> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option> <option value="1900">1900</option> </select><br><br> </li> <li id="li_29" > <label class="description" for="element_29">Sex: </label> <div> <select class="element select medium" id="Sex" name="Sex"> <option value="<?php echo $row['Sex']; ?>" selected="selected"><?php echo $row['Sex']; ?></option> <option value="Male" >Male</option> <option value="Female" >Female</option> </select> </div> </li> <li class="section_break"> <h3>Experience</h3> <p></p> </li> <li id="li_15" > <label class="description" for="element_15">Level: </label> <div> <input id="Level" name="Level" class="element text small" type="text" maxlength="255" value="<?php echo $row['Level']; ?>"/> </div> </li> <li id="li_14" > <label class="description" for="element_14">Services Offered: </label> <div> <textarea id="services" name="services" class="element textarea medium"><?php echo $row['services']; ?></textarea> </div> </li> <li id="li_16" > <label class="description" for="element_16">Philosophy: </label> <div> <textarea id="philosophy" name="philosophy" class="element textarea medium"> <?php echo $row['philosophy']; ?> </textarea> </div> </li> <li id="li_17" > <label class="description" for="element_17">Mission Statement: </label> <div> <textarea id="mission" name="mission" class="element textarea medium"><?php echo $row['mission']; ?></textarea> </div> </li> <li id="li_18" > <label class="description" for="element_18">Customer promises above WGTF promises: </label> <div> <textarea id="customerpromises" name="customerpromises" class="element textarea medium"><?php echo $row['customerpromises']; ?></textarea> </div> </li> <li id="li_19" > <label class="description" for="element_19">Courses undertaken through WGTF: </label> <div> <textarea id="coursesundertaken" name="coursesundertaken" class="element textarea medium"><?php echo $row['coursesundertaken']; ?></textarea> </div> </li> <li id="li_20" > <label class="description" for="element_20">Other Courses: </label> <div> <textarea id="othercourses" name="othercourses" class="element textarea medium"><?php echo $row['othercourses']; ?></textarea> </div> </li> <li id="li_21" > <label class="description" for="element_21">Other non-golf Certifications: </label> <div> <textarea id="nongolfcert" name="nongolfcert" class="element textarea medium"><?php echo $row['nongolfcert']; ?></textarea> </div> </li> <li id="li_30" > <label class="description" for="element_30">CRB Checked: </label> <div> <select class="element select small" id="crbcheck" name="crbcheck"> <option value="<?php echo $row['crbcheck']; ?>" selected="selected"><?php echo $row['crbcheck']; ?></option> <option value="Yes" >Yes</option> <option value="No" >No</option> </select> </div> </li> <li id="li_31" > <label class="description" for="element_31">First Aid Certified: </label> <div> <select class="element select small" id="firstaid" name="firstaid"> <option value="<?php echo $row['firstaid']; ?>" selected="selected"><?php echo $row['firstaid']; ?></option> <option value="Yes" >Yes</option> <option value="No" >No</option> </select> </div> </li> <li id="li_22" > <label class="description" for="element_22">Latest CPD: </label> <div> <textarea id="latestcpd" name="latestcpd" class="element textarea medium"><?php echo $row['latestcpd']; ?></textarea> </div> </li> <li id="li_23" > <label class="description" for="element_23">CPD Goals: </label> <div> <textarea id="cpdgoals" name="cpdgoals" class="element textarea medium"><?php echo $row['cpdgoals']; ?></textarea> </div> </li> <li id="li_24" > <label class="description" for="element_24">Most Influential Coach or Player: </label> <div> <input id="mostinfluential" name="mostinfluential" class="element text medium" type="text" maxlength="255" value="<?php echo $row['mostinfluential']; ?>"/> </div> </li> <li id="li_25" > <label class="description" for="element_25">Main Strengths: </label> <div> <textarea id="mainstrength" name="mainstrength" class="element textarea medium"><?php echo $row['mainstrength']; ?></textarea> </div> </li> <li id="li_26" > <label class="description" for="element_26">Years' Golfing Experience: </label> <div> <input id="yeargolfexperience" name="yeargolfexperience" class="element text small" type="text" maxlength="255" value="<?php echo $row['yeargolfexperience']; ?>"/> </div> </li> <li id="li_27" > <label class="description" for="element_27">Customer Feedback Rating: </label> <div> <input id="customerfeedback" name="customerfeedback" class="element text small" type="text" maxlength="255" value="<?php echo $row['customerfeedback']; ?>"/> </div> </li> <li id="li_28" > <label class="description" for="element_28">WGTF Rating: </label> <div> <input id="wgtffeedback" name="wgtffeedback" class="element text small" type="text" maxlength="255" value="<?php echo $row['wgtffeedback']; ?>"/> </div> </li> <input type='submit' name='Submit' value='Update Profile' /> </form> <div id="footer"> </div> </div> <img id="bottom" src="bottom.png" alt=""> </body> <?php } } ?> Much appreciated Here is my code so far... <head> <script type="text/javascript" src="includes/jquery.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function(){ //trigger when clicking element $(".toggle").click(function () { //check visibility if ($(this).next().is(":hidden")) { $(this).next().slideDown("slow"); //slide it down } else { $(this).next().hide(); //hide it } }); }); </script> </head> <?php include("header.inc"); ?> <table border="0" width="100%"><tr><td valign="top" width="800"> <?php echo "<div id='content'>"; echo "<h2 div id='title'>"; echo "Messages"; echo "</h2>"; if($_SESSION['uid']){ echo "<div align='right'><a href='create_message.php'>Create Message  </a></div>"; echo "<h3 div id='subtitle'>"; echo "Inbox"; echo "</h3>"; //Inbox/////////////////////////////////////////////////////////////// $query = mysql_query("SELECT * FROM messages WHERE to_user='$username' ORDER BY id DESC"); $numrows = mysql_num_rows($query); if ($numrows != 0){ echo "<form action='delete_message.php' method='POST'>"; echo "<div id='messages'> <div id='leftside'>From...</div> <div id='leftside'><input type='submit' name='deleteinbox' value='Delete' class='button'></div> <div id='rightside'>Date</div> <div id='center'>Subject and Message</div> <div style='clear: both;'></div> </div>"; while($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $msg_to_user = $row['to_user']; $msg_to_id = $row['to_id']; $msg_from_user = $row['from_user']; $msg_from_id = $row['from_id']; $msg_subject = $row['subject']; $msg_content = $row['content']; $msg_date = $row['date']; $msg_from_delete = $row['from_delete']; $msg_to_delete = $row['to_delete']; if (!$msg_to_delete){ echo "<div id='messages'>"; echo "<div id='leftside'> <input type='checkbox' name='cb$msg_id' value='$msg_id'> <a href='profile.php?id=$msg_from_id' target='_blank'>$msg_from_user</a> </div>"; echo "<div id='rightside'>$msg_date</div>"; echo "<div id='center'> <span class='toggle'><a href='#'>$msg_subject</a></span> <div class='hiddenDiv'> <br>$msg_content<br><br> <span class='toggle'><a href='#'>REPLY</a></span> <div class='hiddenDiv'> <form action='msgreply.php' method='POST'> <input type='hidden' value='$msg_id' name='replyid'> <input type='text' name='replysubject' style='width: 300px;' class='text-box' value=' $msg_subject'><br> <textarea name='replycontent' style='width: 298px;' rows='5'></textarea><br><br> <input type='submit' name='replybutton' class='button' value='Reply'> </form> </div> </div> </div>"; echo "<div style='clear: both;'></div>"; echo "</div>"; $num += 1; } } if ($num == 0){ echo "You have no messages in your inbox."; } echo "</form>"; } else echo "You have no messages in your inbox!"; }else echo "You must be logged in to view your messages!"; ?> </div> </td><td width="250"> <?php include("sidebar.inc"); ?> </td> </table> </body> </html> <?php include("footer.inc"); ?> Basically I am making a personal messaging system however I can't seem to find a way of putting the reply form "inside" the delete form. Is there any simple answer as I am very new to php. The deletion works fine however whenever I submit a reply it takes me to the delete page! Thanks, Cameron Hi all, I have an html form that sends formdata to a php script called example.php with the POST method. example.php then has the following structu Code: [Select] <?php if(isset($_POST['var1'])) {$var1 = $_POST['var1'];} else {$var1 = 'English';} if(isset($_POST['var2'])) {$var2 = $_POST['var2'];} else {$var2 = 'French';} print" <html> <body> <form> <select id='select1'> <option>var1</option> <option>var2</option> <option>etc...</option> </select> <input type='text' id='input1'> ETC. ETC. </form> </body> </html> "; ?> So example.php has an embedded html form. How do I specify that some elements of the form should take their values from the variables retrieved at the start of the script via the POST command? For example, I want select1 to have 'var1' pre-selected and I want input1 to display var2. var1 & var2 get sent through to example.php fine, I just don't know how to get the embedded html form to use them. Please help! Thanks a lot. |