PHP - I Want A Working Html/php Form.
http://www.apnapaisa...ia/compare.html
just like the form in this page.
Can anybody help me out.
Similar TutorialsHi, I am learning PHP now, so pardon my silly question which I am not able to resolve from a week. I have created a simple web form where in I display the values entered by a user. <form action ="reply.php" id="myForm" method="post" > Name: <input type="text" name="name" size="25" maxlength="50" /> <br> </br> Description: <textarea name="editor1"> </textarea> <input type="submit" value="Submit" /> </form> and reply.php contains: <?php echo "In reply page"; foreach($_POST as $field => $value) { echo "$field = $value"; } ?> When I click on the submit button, I just get a blank page without any values from the form. Can anyone please let me know what am I missing? Set up: I am using Netbeans with PHP bundle added on to it. When i run only a simple php proj it displays that page in localhost/nameofproj, but when I run a php file along with a jsp file, it runs in localhost:8080/nameofproj. Is this the reason(localhost:8080 instead of just localhost ) for showing a blank page, not even a simple echo stmt, when i click on submit? I even re installed netbeans, still no luck. Thanks in advance. 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. 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? I'm trying to submit html/php code through an html form and then insert it into a mysql database. I've got the following code so far (without the insert into database query), however when I submit the form I get pushed through to my 403 page. If i comment out the textarea that contains the code I am trying to submit, then it goes through fine. Any ideas? Code: [Select] <? if (isset($_POST['optone'])) {$optone=$_POST['optone']; $opttwo=$_POST['opttwo'];} if (isset($_POST['type'])) {if ($_POST['type']=='Theory') {$optone=1;} if ($_POST['type']=='Demo') {$optone=2;} $opttwo=$_POST['module'];} ?> <h3>Module administration</h3> <script> function setOptions(chosen) { var selbox = document.myform.opttwo; selbox.options.length = 0; if (chosen == " ") { selbox.options[selbox.options.length] = new Option('Please select an option first',' '); document.myform.go.disabled=true; } if (chosen == "1") { selbox.options[selbox.options.length] = new Option('Module 1','1'); selbox.options[selbox.options.length] = new Option('Module 2','2'); selbox.options[selbox.options.length] = new Option('Module 3','3'); selbox.options[selbox.options.length] = new Option('Module 4','4'); selbox.options[selbox.options.length] = new Option('Module 5','5'); selbox.options[selbox.options.length] = new Option('Module 6','6'); selbox.options[selbox.options.length] = new Option('Module 7','7'); selbox.options[selbox.options.length] = new Option('Module 8','8'); selbox.options[selbox.options.length] = new Option('Module 9','9'); selbox.options[selbox.options.length] = new Option('Module 10','10'); document.myform.go.disabled=false; } if (chosen == "2") { selbox.options[selbox.options.length] = new Option('Module 1','1'); selbox.options[selbox.options.length] = new Option('Module 2','2'); selbox.options[selbox.options.length] = new Option('Module 3','3'); selbox.options[selbox.options.length] = new Option('Module 4','4'); selbox.options[selbox.options.length] = new Option('Module 5','5'); selbox.options[selbox.options.length] = new Option('Module 6','6'); selbox.options[selbox.options.length] = new Option('Module 7','7'); selbox.options[selbox.options.length] = new Option('Module 8','8'); selbox.options[selbox.options.length] = new Option('Module 9','9'); selbox.options[selbox.options.length] = new Option('Module 10','10'); document.myform.go.disabled=false; } } </script> <br /> <center> <form name="myform" method='post'> Edit: <select id="optone" name="optone" size="1" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);" > <option value=" " >--Choose--</option> <option value="1" >Theory</option> <option value="2" >Demo</option> </select> <select name="opttwo" size="1"> <option value=" " selected="selected">Please select an option first</option> </select> <input type='submit' name='go' id='go' value='Go' disabled='disabled'/> </form> </center> <br /><br /> <? if (isset($opttwo)) { if ($optone==1) {$query = "SELECT info,userscompleted,last_user,enabled FROM theorydata WHERE TheoryID=".$opttwo; $typestr='Theory'; $texthelp='Code must be entered in HTML';} if ($optone==2) {$query = "SELECT info,userscompleted,last_user,enabled FROM demodata WHERE DemoID=".$opttwo; $typestr='Demo'; $texthelp='Code must be entered in PHP';} $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $query2="SELECT full_name FROM users WHERE id=".$row['last_user']; $result2 = mysql_query($query2) or die(mysql_error()); $row2 = mysql_fetch_array($result2); ?> <form method='post' > <table> <tr> <td align='center'> Type: </td> <td> <input type='text' name='type' readonly='readonly' value="<? echo $typestr; ?>" /> </td> </tr> <tr> <td align='center'> Module: </td> <td> <input type='text' name='module' readonly='readonly' value="<? echo $opttwo; ?>" /> </td> </tr> <tr> <td align='center' > Enabled? </td> <td> <select name='enabled'> <option value='yes' <? if ($row['enabled'] == '1') {echo "selected='selected'";}?> >Yes</option> <option value='no' <? if ($row['enabled'] == '0') {echo "selected='selected'";}?> >No</option> </select> </td> </tr> <tr> <td align='center'> Code: </td> <td> <center><font color='red'><? echo $texthelp; ?></font></center> <textarea name='info' rows=35 cols=80><? echo htmlentities($row['info']); ?></textarea> </td> </tr> <tr> <td align='center' > Users completed: </td> <td> <input type='text' name='userscompleted' value="<? echo $row['userscompleted']; ?>" size=4/> </td> </tr> <tr> <td align='center' > Last user: </td> <td> <input type='text' name='last_user' readonly='readonly' value="<? echo $row2['full_name']; ?>" /> </td> </tr> <tr> <td></td> <td align='center'> <input type='submit' value='Edit'/> </td> </tr> </table> </form> <? }//close isset(opttwo) ?> Hello! My name is DJ and I am new to PHP. Basically I designed a website with dreamweaver and on one of the pages I have a contact form. I used an internet tutorial to use php in order to finish the form. But now when someone submits their form, I don't receive an email and they just end up at a blank page. I don't understand why it's not working. Can you help me? Code: [Select] <?php /* Subject and Email Variables */ $emailSubject = 'Sales Inquiry'; $webMaster = 'sales@endorsebro.com'; /* Gathering Data Variables */ $name = $_POST['name']; $business_name = $_POST['business_name']; $phone_number = $_POST['phone_number']; $Email = $_POST['Email']; $website = $_POST['website']; $state = $_POST['state']; $budget = $_POST['budget']; $comments = $_POST['comments']; $body = <<<EOD <br><hr><br> Name: $name <br> Business Name: $business_name <br> Phone Number: $phone_number <br> Email Address: $Email <br> Website: $website <br> State: $state <br> Budget: $budget <br> Comments: $comments <br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as html */ $theResults = <<<EOD <html> <head> <title>Endorsebro</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } --> </style> </head> <div> <div align="left">Thank you for your interest! We will be in contact soon!</div> </div> </body> </html> EOD; echo "$theResults"; ?> Thank you for your time. I am using this code to build a form: echo '<form method="post" action="mysql.php">'; echo '<table>'; echo '<tr><td>UserID:</td>'; echo '<td><input type="text" name="username"></td></tr>'; echo '<tr><td>Password:</td>'; echo '<td><input type="password" name="password"></td></tr>'; echo '<tr><td colspan="2" align="center">'; echo '<input type="submit" value="Log In"></td></tr>'; echo '</table></form>'; Alone, this form works, but when I add script above it to make it more functional, everything loads properly and I get no errors, but the form will not submit. The submit button is like a dead button. Anyone know why this could be happening? Heres my code for the whole thing.. <?php if($_GET['view'] == 'vote') { $id="{$_GET['id']}"; if ($list_q = mysql_query("SELECT * FROM toplist WHERE id='$id'")) { if (mysql_num_rows($list_q)) { while($list_b=mysql_fetch_array($list_q)) { if ($list_b['ban'] == 0) { if ($list_b['staff'] == 0) { function capitalizeFirstCharacter($value) { $capitalize = preg_replace('/[a-z]/ie', 'strtoupper($0);', $value, 1); return $capitalize; } if(!empty($_POST['Submit'])) { if($_POST['spampre'] == "4iubg") { mysql_query("UPDATE toplist SET vote++ WHERE id = ". $_SESSION['id']) or die (mysql_error()); echo "<tr><td class='trow2'><span class='smalltext'> Thanks for voting. </span></td></tr>"; }else{ echo "<center>Spam Prevention is wrong.</center>"; } } $result = mysql_query("SELECT * FROM toplist WHERE id='$id'") or die(mysql_error()); $row = mysql_fetch_assoc($result); $id = $row["id"]; ?> <div class="navigation"> <!-- start: nav_bit --> <a href="http://runelegend.com/index.php">Runelegend</a> <!-- end: nav_bit --><!-- start: nav_sep_active --> / <!-- end: nav_sep_active --><!-- start: nav_bit_active --> <a href="http://runelegend.com/toplist">Server List</a> / <span class="active">Viewing <?php echo capitalizeFirstCharacter($list_b['servername']);?></span> <!-- end: nav_bit_active --> </div> <!-- end: nav --> <br /> <!-- end: header --> <form action="server.php?view=vote&id<?php ?>" method="post" id="registration_form"> <table border="0" cellspacing="0" cellpadding="5" class="tborder"> <script type="text/javascript" src="http://runelegend.com/jscripts/captcha.js?ver=1400"></script> <tr> <td><span class="smalltext">Please enter the text contained within the image on the right in to the text box below it. This process is used to prevent automated signups.</span></td> <td rowspan="2" align="center"><img src="http://runelegend.com/captcha.php?action=regimage&imagehash=35a910bc839af4d3c4e36faf471c600c" alt="Image Verification" title="Image Verification" id="captcha_img" /><br /><span style="color: red;" class="smalltext">(don't use caps)</span> </td> </tr> <tr> <td><input type="text" class="textbox" name="spampre" value="" id="spampre" style="width: 100%;" /><input type="hidden" name="imagehash" value="35a910bc839af4d3c4e36faf471c600c" id="imagehash" /></td> </tr> </table> <div align="center"> <input type="submit" class="button" name="Submit" value="Submit Registration!" /> </div> </form> <!-- end: member_profile_adminoptions --> </td> </tr> <?php } else { echo '<font color="red" align="center">There is no need to see this server, It isn\'t even a server, it is a staff member.</font><br/>'; } } else { echo '<font color="red" align="center">This server has been banned.<br>If you are the owner of this server, and wish to know why the server is banned from the list, login and go to the <a href="usercp">UserCP</a></font><br/>'; } }}}} ?> I am pretty much trying to make a Vote for system, but the only Problem Im having is the Form code. When I don't have a php code in the (action) part of the code it works, but If I do then it acts as if it's not even there. Edit: Fixed it. I know this is very simple, but... Any way here is the code for my form, but it doesn't post to my database and there are no errors shown. Any ideas? thanks <? include("include/session.php");?> <? include('include/headder_login.php'); ?> <h1>Event Information : <? echo $session->username; ?></h1> <form> <form action="protimes.php" method="post" name="event information"> <input name="id" type="text" value=""> <input name="name" type="number" value="name" size="30"> <select name="event"> <option value="1">50 Front</option> <option value="2">50 Back</option> <option value="3">100 Front</option> </select> <input name="time" type="time" value"time" > <input name="date" type="date" value="date"> <input name="submit" type="button" value="submit" align="right"> <input type="reset" name="reset" value="reset"aligh="right"> </form> protimes.php file $sql="INSERT INTO `cbcrusta_test3`.`info` ( `id` , `name` , `event` , `time` , `date` ) VALUES ('$_POST[id]','$_POST[name]','$_POST[event]','$_POST[time]','$_POST[date')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "1 record added"; Hey there, Basically I'm having some difficulty getting this form to work: Code: [Select] <form action=getitem.php method=post name=form2><input type=hidden name=itemid value='1'> <input type=image src=items/ricketyoldsledge.png name=free class=img></form> It'll work if it's at the top of the code for the page I want it on, however I want it to be in a later position (I've included the PHP for the whole page below, so hopefully you can see what I mean). The error I get is that the form appears to send, only instead of sending me to getitem.php it just goes back to sledmakers.php. Code: [Select] <?php include('connect.php'); include('header.php'); include('loggedin.php'); echo 'blah blah"'; // Check profession $result = mysql_query("SELECT * FROM players WHERE id=".$_SESSION['id']) or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $profession = $row['profession']; $level = $row['level'];} // if they're unemployed still if($profession == 'Unemployed'){ echo '<br><br><form action=sledmakers.php?talk=yes method=post name=form1> <input type=submit name=submit value="Talk to the man?"><bR><Br>'; } // if they're a Sledmaker elseif($profession == 'Sledmaker'){ echo 'Sledmaker';} // if they're not a Sledmaker else{ echo 'What? You\'re not a Sledmaker! Go away.';} $talk = $_GET['talk']; // if they're unemployed and pressed to speak with her if($talk == 'yes') { echo 'blahblah'; echo 'You look in the corner and find what you\'re looking for...<bR><br>'; ?> <form action=getitem.php method=post name=form2><input type=hidden name=itemid value='1'><input type=image src=items/ricketyoldsledge.png name=free class=img></form> <br><br><form action=sledmakers.php method=post name=form3> <input type=submit name=submit2 value="Become the Master Sledmakers's Apprentice?"><bR><Br> <?php } else{ echo '';} if(isset($_POST['submit2'])){ echo 'You are now an Apprentice Sledmaker!'; } include('footer.php'); ?> Can anybody help me out? :/ If you need more info, please just ask! I'm trying to create a Facebook fangate, and I want an imagemap to come up to fans, but a static image to come up for non-fans. Here's the code. Someone please tell me what I'm doing wrong. I've tried it 3 different ways. (I searched Google and this forum before posting...nothing I found worked for me). While I've removed identifying information, I have tested and made sure the bitmapped image works properly (can call it through facebook on its own) as well as the regular image. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <link rel="stylesheet" type="text/css" href="style.css" /> <style type="text/css"> body { width:520px; margin:0; padding:0; border:0; }</style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <? require 'facebook.php'; $app_id = "XXXXXXXXX"; $app_secret = "XXXXXXXXXXX"; $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'cookie' => true )); $signed_request = $facebook->getSignedRequest(); if ($like_status) { ?> <div><img src="http://xxxxxx.com/facebook/FBnavbar.png" alt="" usemap="#FB Nav Bar" style="border-style: none" /></div> <div> <map id="FB Nav Bar" name="FB Nav Bar"> <area shape="rect" alt="About xxxxxx Social Media" coords="6,21,80,42" href="http://www.facebook.com/xxxxxxx?sk=info" title="About xxxxxx Social Media" /> <area shape="rect" alt="xxxxxx Blog" coords="222,24,276,38" href="http://www.facebook.com/xxxxxxxsk=app_?????" title="xxxxxx Blog" /> <area shape="rect" alt="xxxxxx Social Media" coords="297,23,391,39" href="" title="xxxxxx Social Media" /> <area shape="rect" alt="Contact xxxxxx Social Media" coords="409,23,508,39" href="../../../contact/" title="Contactxxxxxx Social Media" /> <area shape="rect" alt="Subscribe to our RSS feed" coords="443,1,459,14" href="http://feedburner.com/xxxxx" title="Subscribe to our RSS feed" /> <area shape="rect" alt="Share us on delicious" coords="463,0,478,18" href="http://www.delicious.com/share?new=1&hash=e16eda577a70c83c0dfa2c8c29e52d24&key=tnNrKLSea55V6Tkd2ze9ujDWVOs-&title=xxxxxxx%2xxxxp%20Reputation%20Management&url=http%3A%2F%2Fxxxxxxx%2F&jump=%2Furl%2Fe16eda577a70c83c0dfa2c8c29e52d24" title="Share us on delicious" /> <area shape="rect" alt="Add us on LinkedIn" coords="485,3,499,18" href="http://www.linkedin.com/company/xxxxxx" title="Add us on LinkedIn" /> <area shape="rect" alt="Follow our Director on Twitter" coords="503,1,519,17" href="http://www.twitter.com/xxxxxxx" title="Follow our Director on Twitter" /> <area shape="rect" alt="Learn about xxxxxxxx's Services" coords="98,21,202,40" href="http://www.facebook.com/xxxxxx?sk=app_?????" title="Learn about xxxxxxx's Services" /> <area shape="default" nohref="nohref" alt="" /></map></div> <?php } else { ?> <img src="http://xxxxx.com/facebook/landing/SRfanpage3.png" /> <?php } ?> </body> </html> I'm very new at this (not a php coder, just grabbed some code from a tutorial and am trying to make it work), so please be gentle. Thanks for your help in advance. I wrote the search form below to enable users search other users of a site based on certain criteria like age, race etc. Then I wrote the php script beneath, to execute that search. I decided to make the script very simple, searching only for one criterion for now (ethnicity). So even though I have several fields in the search form, I wrote the script to process only one of those fields(ethnicity). So basically, the script searches all records for members on the site from two tables called images and members(the members table has an "ethnicity column"), who meet the user's ethnicity preference and returns certain columns for all members who meet that preference. Well when I click the submit button, all I get is "Form not submitted". I added that form not submitted clause at the end of the script just after I had tweaked the script in every way possible but got nothing but a blank page every time I submitted the form. So take a look people and tell me what could be going wrong here. Appreciate any help. Code: [Select] <form id="search_profiles_form" action= "profile_search.php"> Seeking A: <select name= "sex"> <option value= "man">Man</option> <option value= "woman">Woman</option> <option value= "both">Both</option> <select> <p> <tab> Age Range: <?php print '<select name= "min_age">'; for ($age = 18; $age <= 99; $age++) { print "\n<option value=\"$age\">$age</option>"; } print '</select>'; ?> </tab> <tab> and: <?php print '<select name= "max_age">'; for ($age = 18; $age <= 99; $age++) { print "\n<option value=\"$age\">$age</option>"; } print '</select>'; ?> </tab> </p> <p>Distance: <select name= "distance"> <option name="5">Within 5 Miles</option> <option name="10">Within 10 Miles</option> <option name="50">Within 50 Miles</option> <option name="100">Within 100 Miles</option> <option name="250">Within 250 Miles</option> <option name="any">Beyond 250 Miles</option> </select> </p> <p>Ethnicity: <select name= "ethnicity"> <option name="black">Black/African Descent</option> <option name="white">Caucasian?European Descent</option> <option name="latino">Hispanic Non White</option> <option name="asian">Asian Descent</option> <option name="native_american">Native American</option> <option name="pacific_islander">Pacific Islander</option> <option name="indian">Indian Descent</option> <option name="middle_east">Middle Eastern</option> <option name="other">Other</option> </select> </p> <p>Last Active: <select name= "last_active"> <option name="0">Online Now</option> <option name="1">1 Hr Ago</option> <option name="5">5 Hrs Ago</option> <option name="24">24 Hrs Ago</option> <option name="1wk">1 Week Ago</option> <option name="3wk">Over 3 Weeks Ago</option> </select> </p> <input type="hidden" name="submitted" value="TRUE"/> <p> <input type ="submit" value="Search!"/> </p> </form> And here goes the php script. Code: [Select] <?php //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); //authenticate user require('auth.php'); if (isset($_POST['submitted'])) { // Connect to the database. require_once ('config.php'); //Query the database. $sql = "SELECT * FROM members INNER JOIN images ON members.member_id = images_member_id WHERE members.ethnicity = '{$_POST['ethnicity']}' AND images.cartegory = 'main' "; $query = mysql_query($sql); //Check for success here. if(!$query) { trigger_error("SQL query $sql failed: " . mysql_error(), E_ERROR); // Handle as desired }else{ //If query is valid. if(mysql_num_rows($query) > 0){ while ($row = mysql_fetch_assoc($query)){ //Redirect to search results page. echo $_POST['ethnicity']; echo $row['member_id']; echo $_SESSION['id']; echo $row['image']; } }else {//No rows returned. echo 'No results match this search query.' ; } }//End of else if query is valid. }else{ echo "form not submitted";} ?> Hi Guys, I am sure you will laugh at my coding attempt, but i need your help. I have set up a contact form and a PHP process to send the email. Everything appears to be working except the sending part. All fields validate as they should, the form forward to a thank you page as it should. But no emails are received either at my domain end or from the sender i am testing with. Here is my form code: Code: [Select] <form id="form1" name="form1" method="post" action="emailform.php" onsubmit="window.setTimeout(function(){window.location='/thankyou.html'},20); return true;"> <p><span id="sprytextfield1"> <label for="name">Name: </label> <input name="name" type="text" id="name" tabindex="10" /> <span class="textfieldRequiredMsg">Your name is required.</span><span class="textfieldMaxCharsMsg">No more than 50 characters in your Name.</span><span class="textfieldMinCharsMsg">Your Name must be atleast 4 characters long.</span></span></p> <p><span id="sprytextfield2"> <label for="email">Email: </label> <input type="text" name="email" id="email" tabindex="20" /> <span class="textfieldRequiredMsg">An Email Address is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></p> <p><span id="spryselect1"> <label for="state">State</label> <select name="state" id="state" tabindex="30"> <option>ACT</option> <option>NSW</option> <option>Queensland</option> <option>Victoria</option> <option>Tas</option> <option>SA</option> <option>WA</option> <option>NT</option> </select> <span class="selectInvalidMsg">Please select a valid State.</span></span></p> <p>What styles are you interested in doing? <label for="styles"></label> <select name="styles" id="styles" tabindex="40"> <option>Portraits</option> <option>Fashion</option> <option>Swimwear</option> <option>Lingerie</option> <option>Art Nude</option> <option>All Styles Possible</option> <option>Just Curious for Now</option> </select> </p> <p>Please leave any Message or Comments Below:</p> <p><span id="sprytextarea1"> <label for="comments"></label> <textarea name="comments" id="comments" cols="45" rows="5" tabindex="50"></textarea> <span class="textareaRequiredMsg">Please enter your comments here.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></p> <p> <label for="submit"></label> <input type="submit" name="submit" id="submit" value="Send Form" tabindex="50" /> </p> </form> Here is the PHP Code: <?php /* Subject and variables */ $emailSubject = 'New Email Enquiry'; $webMaster = 'enquiry@davids-photography.com'; /* Gathering data variables */ $nameField = $_POST['name']; $emailField = $_POST['email']; $stateField = $_POST['state']; $stylesField = $_POST['styles']; $commentsField = $_POST['comments']; $body = <<<EOD <br><hr><br> Name: $name <br> Email: $email <br> State: $state <br> Style: $style <br> Comment: $comments <br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); ?> Any help you can offer would be greatly appreciated. I am not looking for anything over the top, just something simple that works. Thanks David I want to make it so that whoever is sending the fame (sender) doesn't send it to themselves (receiver). However, I can't get it to block that. Everything else works, so something must be up with that specific requirement. Any help would be appreciated! Thanks! <?php //error_reporting(E_ALL); //ini_set('display_errors', 1); include("fightfunc.php"); include("lib.php"); define("PAGENAME", "GFame"); $player = check_user($secret_key, $db); $x = $player->username; if($_SESSION['234asdfas']){$y = $_SESSION['234asdfas'];}else{echo 'Error: You do not have a session variable set'; exit;} $command = 1; if (isset($_POST["sendfame"])) { $maxgfame = $player->gfame; include("tmpconfig.php"); $checkquery = mysql_query("SELECT * FROM `users` WHERE `username`='".ucwords(strtolower($_POST['receiver']))."'"); extract($_POST); if($sender == "") { echo "You must put a sender's name in the text box.";//The amount would create a negative balance - implement error condition } elseif ($gfamesent == 0) { echo "Enter an amount greater than 0."; } elseif ($gfamesent < 0) { echo "Enter an amount greater than 0."; } elseif (!is_numeric($gfamesent)) { echo "Enter a numerical amount!"; } elseif ($gfamesent == "") { echo "Enter a numerical amount!"; } elseif ($receiver == "") { echo "You must put a name in the Receiver field."; } elseif ($gfamesent > $maxgfame) { echo "You don't have that much gfame to give."; } elseif ($receiver == $sender) { echo "You can't give gfame to yourself."; } elseif (mysql_num_rows($checkquery) == 0) { echo "That player does not exist."; } else { $query = $db->execute("UPDATE `users` SET `gfame`=? WHERE `id`=?", array($player->gfame - 1, $player->id)) or die("querya failed: ". mysql_error()); if($query) $qry = $db->execute("select * from `users` where `username`=?", array(ucwords(strtolower($_POST['reciever'])))) or die("qry failed: ".mysql_error()); $rw = $qry->fetchrow(); if($qry){ $query2 = $db->execute("UPDATE `users` SET `fame`=? WHERE `username`=?", array($rw['fame'] + 1, $rw['username'])) or die("query2 failed: ". mysql_error()); if($query2){ echo("<br><br>You have successfully transfered your gfame over.<br>"); } } }} $player = check_user($secret_key, $db); ?> <br /><br /><blockquote><center>GFame is fame you can award 1 other person for what you feel is "noteworthiness". In otherwords, if you feel someone is doing a superb job of role-playing their character, you can "reward" them for their actions. You may send 1 gfame point per day. And no, you cannot send it to yourself.</center></blockquote><br /><br /> <table width="100%"> <tr> <td colspan="2"><fieldset> <legend>Transfer GFame:</legend> You have <b><?=$player->gfame?></b> GFame to give.<br /> <form method="post" action="gfame.php"> <input name="sender" type="hidden" value="$player->id" id="sender" /> <input type="submit" value="Transfer" name="sendfame"> <input type="text" value="1" name="gfamesent"> to <input name="receiver" type="text" id="receiver"> </form> </fieldset></td> </tr> </table> Hi, thanks in advance for any help here. I have a PHP 'contact us' form on my website that recently stopped returning the information that gets entered into the form. I don't know why it's no longer working and was hoping someone here could help. It's worked for the last 4 years and only stopped working within the last week. I still get the email, but none of the information is returned, only blanks. Any ideas? Here's the script I'm using: Code: [Select] <?php /*----------------------*/ /* URL of the site. */ /*----------------------*/ $site_URL = "http://www.Website.com/"; /*----------------------*/ /* Name of the site. */ /*----------------------*/ $site_Name = "Website.com"; /*----------------------*/ /* ADMIN email id. */ /*----------------------*/ $admin_from = "webmaster@Website.com"; /*----------------------*/ /* ADMIN email id to which comments are sent. */ /*----------------------*/ $admin_email = "info@Website.com"; $name = $_REQUEST["firstname"]; $lastname = $_REQUEST["lastname"]; $email = $_REQUEST["email"]; $zipcode = $_REQUEST["zipcode"]; $phone = $_REQUEST["phone"]; $message = $_REQUEST["message"]; $subject = "$site_Name has Received your Message"; $sendmessage = "<font face='tahoma, verdana, arial, helvetica' size=2>New Comments Received...<br><br>"; $sendmessage .= "<strong>Name:</strong> $name $lastname<br>"; $sendmessage .= "<strong>Zipcode:</strong> $zipcode<br>"; $sendmessage .= "<strong>Phone:</strong> $phone<br>"; $sendmessage .= "<strong>Email:</strong> <a href='mailto:$email' style='color:#6095cc; text-decoration: none;'>$email</a><br>"; $sendmessage .= "<strong>Message:</strong> $message<br>"; $sendmessage .= "<br><a href='$site_URL' target=_blank>$site_Name</a></font>"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .="From: $site_Name Registration <$admin_from>\n"; mail($admin_email, $subject, $sendmessage, $headers); $reply_msg = "<font face='tahoma, verdana, arial, helvetica' size=2>Thank you for your comments at $site_Name. We will reply soon!<br>"; $reply_msg .= "<br>- <a href='$site_URL' target=_blank>$site_Name</a></font>"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .="From: $site_Name<$admin_from>\n"; // send an email to confirm the referer. mail($email, "$site_Name - Your comments have been received!", $reply_msg, $headers); ?> <center> <font face='tahoma, verdana, arial, helvetica' color='#333333'> <h2> <?=$site_Name?> </h2> <p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Please wait while your comments are being sent.</strong>.<br /> If your page does not refresh automatically, <a href="<?=$site_URL?>">Click Here</a>.</font></p> </center> <script language="javascript"> window.location.href = "<?=$site_URL?>"; </script> MOD EDIT: [code] . . . [/code] BBCode tags added. Form forward is not working in below code. Once I click on submit button, it is not forwarding the results to codetesting.php. <html> <head> </head> <body> <form method="post" action="codetesting.php"> <select name="Para"> <option value="Yes"> Yes </option> <option value="No"> No </option> <option value="NA"> NA </option> </select> </form> <input type="submit" name="submit" value="Submit"> </body> </html> Hi, I'm trying to make a form sticky but when I display it on the web I get a blank page. I'm following the example given in my PHP book I'm wondering if there 's an error in the book because it has 2 opening form tags which I didn't think was right. Code: [Select] <!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>Untitled Document</title> </head> <body> <?php $errors=array(); if(isset($_POST['submit'])){ validate_input(); //checks for empty fields if(count($errors) !=0){ display_form(); } else { display_form(); } } function validate_input(){ global $errors; if($_POST["name"] == ""){ $errors['name']="<font color='red'> please enter your name </font>"; } } function display_form(){ global $errors; ?> <form action="" method="post"> Name: <input name="name" type="text" size="10" maxlength="10" value = "<?php echo $_POST[name]; ?>"/> <br /> <?php echo $errors['name']; ?> <br /> Email: <input name="email" type="text" size="15" maxlength="30" /><br /> <input name="submit " type="submit" value="submit " /> </form> <?php } ?> </body> </html> Hi, I am new to php, and I have run into a problem. The tutorial I am using has provided me with this exact code. But it does not work for me. Its very simple. Here is the HTML page: Code: [Select] <body> <FORM ACTION="welcome.php" METHOD=POST> First Name: <INPUT TYPE=TEXT NAME="name"> <INPUT TYPE=SUBMIT VALUE="GO"> </FORM> </body> And here is the php page: <body> <?php echo( "Welcome to our Web site, $name!" ); ?> </body> You can see the problem live at <http://www.freewaycreative.com/test> (dont mind the digits below) The name just does not show. Anyone know why? Thanks! Hey guys, I'm using a PHP form for my website & I can't get it to send the email correctly, all it send me is the first and last name, but none of the other boxes, any help? Also how can I secure it?
This is the PHP file:
<!DOCTYPE html> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Contact Us</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <!-- Template 2043 Pinky Flow http://www.tooplate.com/view/2043-pinky-flow --> <link href="css/tooplate_style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" /> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/ddsmoothmenu.js"> /*********************************************** * Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ </script> <script type="text/javascript"> ddsmoothmenu.init({ mainmenuid: "tooplate_menu", //menu DIV id orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v" classname: 'ddsmoothmenu', //class added to menu's outer DIV //customtheme: ["#1c5a80", "#18374a"], contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"] }) </script> <link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" /> <!-- Arquivos utilizados pelo jQuery lightBox plugin --> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script> <link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" /> <!-- / fim dos arquivos utilizados pelo jQuery lightBox plugin --> <!-- Ativando o jQuery lightBox plugin --> <script type="text/javascript"> $(function() { $('#map a').lightBox(); }); </script> </head> <body> <div id="tooplate_wrapper"> <div id="tooplate_header"> <div id="site_title"><h1><a href="index.html">Rubi Noodle Studios</a></h1></div> <div id="tooplate_menu" class="ddsmoothmenu"> <ul> <li><a href="index.html" class="selected"><span></span>Home</a></li> <li><a href="gallery.html"><span></span>Galleries</a> <ul> <li><a href="families.html">Families</a></li> <li><a href="children.html">Children</a></li> <li><a href="graduates.html">Graduates</a></li> <li><a href="engagement.html">Engagement</a></li> <li><a href="weddings.html">Weddings</a></li> <li><a href="maternity.html">Maternity</a></li> </ul> </li> <li><a href="information.html"><span></span>Information</a> <ul> <li><a href="announcements.html">Graduation Announcements</a></li> <li><a href="pricing.html">Pricing</a></li> <li><a href="hints.html">Helpful Hints</a></li> </ul> </li> <li><a href="client.html"><span></span>Client Viewing</a></li> <li><a href="contact.html" class="selected"><span></span>Contact</a></li> <li><a href="http://www.facebook.com"> <img src="images/facebook.png" alt="Facebook" style="width:33px;height:32px;border:0" /> </a></li> </ul> <br style="clear: left" /> </div> <!-- end of tooplate_menu --> <div id="tooplate_main"> <div id="tooplate_content"> <h2>Contact Information</h2> <p><em>Have a question about a session or want to set up a session? Please feel free to contact me.</em></p> <div class="h30"></div> <div class="col_w420 float_l"> <div id="contact_form"> <h3>Quick Contact Form</h3> <?php if (isset($_POST['submit'])) { if ($_POST['author'] != "") { $_POST['author'] = filter_var($_POST['author'], FILTER_SANITIZE_STRING); if ($_POST['author'] == "") { $errors .= 'Please enter a valid name.<br/><br/>'; } } else { $errors .= 'Please enter your name.<br/>'; } if ($_POST['email'] != "") { $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>"; } } else { $errors .= 'Please enter your email address.<br/>'; } if ($_POST['subject'] != "") { $email = filter_var($_POST['subject'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= 'Please enter a subject.<br/></br>'; } } else { $errors .= 'Please enter your subject.<br/>'; } if ($_POST['text'] != "") { $_POST['text'] = filter_var($_POST['text'], FILTER_SANITIZE_STRING); if ($_POST['text'] == "") { $errors .= 'Please enter a message to send.<br/>'; } } else { $errors .= 'Please enter a message to send.<br/>'; } if (!$errors) { $author=$_POST['author']; $email=$_POST['email']; $subject = 'Vistor:Email'; $text=$_POST['text']; mail("myemail@yahoo.com","$subject", $text,"From: $author <$email>"); header("Location:contact.php?thankyou"); exit(); } else { echo '<div style="color: red">' . $errors . '<br/></div>'; } } ?> <?php //Then outside the processing script add if (isset($_GET['thankyou'])){ echo "Thank you for your email!<br/><br/>"; } ?> <form method="post" name="form1" action="contact.php" /> <label for="author">* Name:</label> <input type="text" id="author" name="author" class="required input_field" value="<?php echo $_POST['author']; ?>"/> <div class="cleaner h10"></div> <label for="email">* Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" value="<?php echo $_POST['email']; ?>" /> <div class="cleaner h10"></div> <label for="subject">* Subject:</label> <input type="text" class="validate-subject required input_field" name="subject" id="subject" value="<?php echo $_POST['subject']; ?>" /> <div class="cleaner h10"></div> <label for="text">* Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required" value="<?php echo $_POST['text']; ?>" ></textarea> <div class="cleaner h10"> </div> <input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" /> <input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" /> </form> </div> </div> <div class="col_w420 float_r"> <h3>Location</h3> <div id="map"> <a href="images/map_big.png" title="Our Location"> <img width="300" height="150" src="images/map_thumb.png" alt="Location" class="image_wrapper" /> </a> </div> <div class="cleaner h30"></div> <h3>Mailing Address</h3> <h6>Address</h6> Address <br /> <br /> <br /><br /> <strong>Phone:</strong> 020-054-1520<br /> <strong>Email:</strong> <a href="mailto:info@company.com">info@company.com</a> </div> <div class="cleaner"></div> </div> <div class="cleaner"></div> </div> <!-- end of tooplate_main --> <div id="tooplate_footer"> Copyright © 2014 <a href="index.html">Rubi Noodle Studios</a> | Design: <a href="http://www.tooplate.com">tooplate</a> <div class="cleaner"></div> </div> </div> <!-- end of forever header --> </div> <!-- end of forever wrapper --> </body> </html>When I run my contact form on my webserver and fill it out completely and submit it, I get my error message saying "Please enter a subject." when I have a subject. Hey everyone I'm pretty new at PHP so i'm hoping someone can help me with this code. What I am trying to do is if someone selects a state say Kansas then fills out the rest of the form and clicks submit it will go to a specific email address. If someone selects another state like Nebraska it will go to a separate email address. Here is my code and I hope someone can help me with this. PS I think I really screwed this one up lol :help: Thanks, B Code: [Select] <?php /* Subject and Email variables */ $emailSubject = 'Your Car Report Info.'; $webMaster = 'me@rustyeckford.com'; $webMaster2 ='me1@rustyeckford.com'; $webMaster3 ='me2@rustyeckford.com'; /* Gathering Data Variables */ $f_nameField = $_POST['f_name']; $l_nameField = $_POST['l_name']; $addField = $_POST['Address']; $stateField = $_POST['state']; $phoneField = $_POST['phone']; $emailField = $_POST['email']; $vinField = $_POST['vin']; $body = <<<EOD <br><hr><br> First Name: $f_name <br> Last Name: $l_name <br> Address: $Address <br> State: $state <br> Phone: $phone <br> Email: $email <br> VIN: $vin <br> EOD; switch($state) { case 'Kansas': case 'Oklahoma': $wm = $webMaster2; break; case 'Missouri': case 'Iowa': $wm = $webMaster3; break' case 'Nebraska: $wm = $webMaster; break; } $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($wm, $emailSubject, $body, $headers); /* Results rendered from Html */ $theResults = <<<EOD <html> <head> <title>Your Car Report - Results</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } </style> </head> <div> <div align="center">Thank you for your submission. Your vehicle report will be provided to you very soon!</div> </div> </body> </html> EOD; echo "$theResults"; ?> |