Jump to content

Search the Community

Showing results for tags 'forms'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. I'm working on this quiz. Something has gone wrong with my form though. The page displays a random question but instead of showing 4 different answer options, it repeats one option 4 times. How do should I go about fixing this? <?php SESSION_START(); //Connect to MySQL: $con = new mysqli("localhost", "root", "", "quizproject"); ?> <html> <body> <h1>Hello, <?php echo $_SESSION["fname"]; " " ?> <?php echo $_SESSION["lname"]; ?>.</h1> <p><h2>Quiz Time! Please answer each of the following questions:</h2><br> <?php //retrieve question list: $get_questions = $con->prepare("SELECT question_ID, question FROM questions"); $get_questions->execute(); $get_questions->bind_result($question_ID, $question); $questions = array(); while ($get_questions->fetch()) { $questions[$question_ID] = array($question_ID, $question, array()); } // retrieve answer list: $get_answers = $con->prepare("SELECT id, question_ID, answers, correct FROM answers"); $get_answers->execute(); $get_answers->bind_result($id, $question_ID, $answers, $correct); while ($get_answers->fetch()) { $questions[$question_ID][2][$id] = array($id, $answers, $correct); } // Scramble the array and print: shuffle($questions); ?> <form method="get" action="result.php"> <div class="question"> <label><h2><?php echo $question ?></h2></label> <br> <input type="hidden" name="question<?php echo $question_ID ?>_id" value="<?php echo $question_ID; ?>" id="question<?php echo $question_ID; ?>_id"/> <input name="answer<?php echo $id ?>" id="q<?php echo $id ?>_a1" value="1" type="radio"/> <label for="q<?php echo $id ?>_a1"> <?php echo $answers ?></label><br> <input name="answer<?php echo $id?>" id="q<?php echo $id ?>_a2" value="2" type="radio"/> <label for="q<?php echo $id ?>_a2"> <?php echo $answers ?></label><br> <input name="answer<?php echo $answers ?>" id="q<?php echo $id ?>_a3" value="3" type="radio"/> <label for="q<?php echo $id ?>_a3"> <?php echo $answers ?></label><br> <input name="answer<?php echo $id ?>" id="q<?php echo $id ?>_a4" value="4" type="radio"/> <label for="q<?php echo $id ?>_a4"> <?php echo $answers ?></label><br> </div> <?php echo "<br><input name=\"submit\" type=\"submit\" value=\"Submit\">"; echo "</form></body></html>"; ?> </form> </html> </body>
  2. Hi! We have a form that's been used for years, and now we would like to have the added capability of attaching an image. (So a consumer can send us an image that might help with their problem.) Currently, a "confirmation" email is sent to the consumer with all of the info they gave us; a copy of the same information also goes to us. We would like the consumer's image to be saved onto our server, so when we look at the completed form, the "Image:" line has a link to that page. I.e. a consumer attaches an image named "picture.jpg". The copy of the information we get would have a line that reads: "Image: http://www.example.com/test/uploads/picture.jpg". I'm assuming I would use a variable to get the image name to display in order to complete the link. I'm lost about which variable I would use... but that might be because I can't get the image to even save in the folder (I think) it's supposed to. Obviously there's something messed up, but I am lost as to what that is. Any help would be greatly appreciated! The field to attach the image on the form: <label for="upload_file" class="main-label">If you have an image that would help us assist you, please attach it here.</label> <input type="file" name="uploaded_file"> The process file (the attachment part is at the bottom): <?php //Collect contact form data //Check Special Field //Email ASC & Webmaster //Email Sender //Redirect to thank you page require_once($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php'); /******** CONTACT DATA **********/ $name = stripslashes($_POST['name']); $company = stripslashes($_POST['company']); $address = stripslashes($_POST['address']); $city = stripslashes($_POST['city']); $state = stripslashes($_POST['state']); $zipcode = stripslashes($_POST['zipcode']); $country = stripslashes($_POST['country']); $website = $_POST['website']; $phone = stripslashes($_POST['phone']); $fax = stripslashes($_POST['fax']); $email = stripslashes($_POST['contact']); $Referred = stripslashes($_POST['referred']); $CustomerType = stripslashes($_POST['CustomerType']); $Comments = stripslashes($_POST['comments']); $ConsumerHelp = stripslashes($_POST['ConsumerHelp']); $UPC = stripslashes($_POST['UPC']); $Describe = stripslashes($_POST['Describe']); $uploaded_file = ($_FILES['uploaded_file']); /******** CHECK SPECIAL FIELD **********/ $spamcheck = stripslashes($_POST['email']); //if spamcheck isnt blank exit page, no need for error message to user, as its a spam bot if ($spamcheck!=="") { exit; } /******** EMAIL ASC & WEBMASTER **********/ $message = " ----------------------------------------------------------------------------- Information Inquiry ----------------------------------------------------------------------------- $name has visited the web site and would like some information. The details they entered on the website are: Name: $name Company: $company Address: $address City: $city State: $state Zip Code: $zipcode Country: $country Website: $website Phone: $phone Fax: $fax Email: $email Referred to web site: $Referred CustomerType: $CustomerType Comments: $Comments I need help with: $ConsumerHelp UPC code or Item #: $UPC What I am looking for: $Describe Image: $uploaded_file Kind Regards, "; $email_address = "example@example"; $subject = "Information Inquiry"; $headers = "From: $name <$email>"; $message = str_replace("\r",'',$message); //fixes postfix php bug that double spaces messages /******** EMAIL SENDER **********/ $message2 = " ----------------------------------------------------------------------------- Re: Information Inquiry ----------------------------------------------------------------------------- Thank you $name for visiting the web site. We will be using the details you entered to contact you. Name: $name Company: $company Address: $address City: $city State: $state Zip Code: $zipcode Country: $country Website: $website Phone: $phone Fax: $fax Email: $email Referred to web site: $Referred CustomerType: $CustomerType Comments: $Comments I need help with: $ConsumerHelp UPC code or Item #: $UPC What I am looking for: $Describe Kind Regards, "; $email_address2 = "$email"; $subject2 = "Re: Information Inquiry"; $headers2 = "From: <example@example.com>"; $message2 = str_replace("\r",'',$message2); //fixes postfix php bug that double spaces messages //send message 1 and save result in success var (either true for success, or false for fail $success = mail($email_address, $subject, $message, $headers); //conditionally send message2, no need to check success on this one if (strpos($email,'@aol.com') == false) { mail($email_address2, $subject2, $message2, $headers2); } if (!$success) { // What happens when the form does not validate header("Location: sorry.php"); die (); } else { // Your code here to handle a successful verification header("Location: thanks.php"); $success; } ?> <?php $allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["uploaded_file"]["name"]); $extension = end($temp); if ((($_FILES["uploaded_file"]["type"] == "image/gif") || ($_FILES["uploaded_file"]["type"] == "image/jpeg") || ($_FILES["uploaded_file"]["type"] == "image/jpg") || ($_FILES["uploaded_file"]["type"] == "image/pjpeg") || ($_FILES["uploaded_file"]["type"] == "image/x-png") || ($_FILES["uploaded_file"]["type"] == "image/png")) && ($_FILES["uploaded_file"]["size"] < 20000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["uploaded_file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["uploaded_file"]["name"] . "<br>"; echo "Type: " . $_FILES["uploaded_file"]["type"] . "<br>"; echo "Size: " . ($_FILES["uploaded_file"]["size"] / 1024) . " kB<br>"; echo "Temp file: " . $_FILES["uploaded_file"]["tmp_name"] . "<br>"; if (file_exists("upload/" . $_FILES["uploaded_file"]["name"])) { echo $_FILES["uploaded_file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "upload/" . $_FILES["uploaded_file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
  3. I'm having a bit of trouble with a PHP contact form. There are issues with the error messages not showing on the form, the form not resetting, and the "name" input appearing as "X-AuthUser: XXX123 (which happens to be my FTP user name which I'm keeping private) when the email is sent to my gmail account. This is how the theme should look: http://pluto.html.themewoodmen.com/07-pluto-contact.html And this is what I have: http://divagraphics.us/test/contact.html The HTML <div class="contactForm"> <div class="successMessage alert alert-success alert-dismissable" style="display: none"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> Thank You! E-mail was sent. </div> <div class="errorMessage alert alert-danger alert-dismissable" style="display: none"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> Ups! An error occured. Please try again later. </div> <form class="liveForm" role="form" action="form/send.php" method="post" data-email-subject="Contact Form" data-show-errors="true" data-hide-form="false"> <fieldset> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label class="control-label">Name <span>(Required)</span></label> <input type="text" required name="name" class="form-control" id="name"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="control-label">Email <span>(Required)</span></label> <input type="email" required name="email" class="form-control" id="email"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Subject</label> <input type="text" name="subject" class="form-control" id="subject"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Message <span>(Required)</span></label> <textarea name="message" required class="form-control" rows="5" id="message"></textarea> </div> </div> </div> <input type="submit" class="btn btn-primary" value="Send Message"> </fieldset> </form> </div> The JS /** * Contact Form */ jQuery(document).ready(function ($) { "use strict"; $ = jQuery.noConflict(); var debug = false; //show system errors $('.liveForm').submit(function () { var $f = $(this); var showErrors = $f.attr('data-show-errors') == 'true'; var hideForm = $f.attr('data-hide-form') == 'true'; var emailSubject = $f.attr('data-email-subject'); var $submit = $f.find('[type="submit"]'); //prevent double click if ($submit.hasClass('disabled')) { return false; } $('[name="field[]"]', $f).each(function (key, e) { var $e = $(e); var p = $e.parent().find("label").text(); if (p) { var t = $e.attr('required') ? '[required]' : '[optional]'; var type = $e.attr('type') ? $e.attr('type') : 'unknown'; t = t + '[' + type + ']'; var n = $e.attr('name').replace('[]', '[' + p + ']'); n = n + t; $e.attr('data-previous-name', $e.attr('name')); $e.attr('name', n); } }); $submit.addClass('disabled'); $f.append('<input class="temp" type="hidden" name="email_subject" value="' + emailSubject + '">'); $.ajax({ url: $f.attr('action'), method: 'post', data: $f.serialize(), dataType: 'json', success: function (data) { $('span.error', $f).remove(); $('.error', $f).removeClass('error'); $('.form-group', $f).removeClass('has-error'); if (data.errors) { $.each(data.errors, function (i, k) { var input = $('[name^="' + i + '"]', $f).addClass('error'); if (showErrors) { input.after('<span class="error help-block">' + k + '</span>'); } if (input.parent('.form-group')) { input.parent('.form-group').addClass('has-error'); } }); } else { var item = data.success ? '.successMessage' : '.errorMessage'; if (hideForm) { $f.fadeOut(function () { $f.parent().find(item).show(); }); } else { $f.parent().find(item).fadeIn(); $f[0].reset(); } } $submit.removeClass('disabled'); cleanupForm($f); }, error: function (data) { if (debug) { alert(data.responseText); } $submit.removeClass('disabled'); cleanupForm($f); } }); return false; }); function cleanupForm($f) { $f.find('.temp').remove(); $f.find('[data-previous-name]').each(function () { var $e = jQuery(this); $e.attr('name', $e.attr('data-previous-name')); $e.removeAttr('data-previous-name'); }); } }); The PHP <?php // Contact subject $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $to = "divagraphicsinc@gmail.com"; $from = $_POST['email']; $headers = "From: $from"; mail($to,$subject,$message,$headers) ?>
  4. Hi guys I've cobbled together this script to process a form with a file attachment. It works fine but it doesn't have any validation for the form or the file which isn't great and I'd like to add, currently I'm just using Javascript validation. Before I move on to the validation, can you see why the form processes twice? I get one email with the processed info and one or two blank. My knowledge of PHP is beginner at best. My code. Thanks in advance. <?php $recipient = "richard@domain.com"; $subject = "Job Application"; $message .= "Name: {$_POST['name']} \n\n"; $message .= "Date of Birth: {$_POST['dob']} \n\n"; $message .= "Telephone: {$_POST['telephone']} \n\n"; $message .= "Email: {$_POST['email']} \n\n"; $message .= "Home Address: {$_POST['address']} \n\n"; $message .= "The Question Section\n\n"; $message .= "Showroom answer: {$_POST['showroom']} \n\n"; $message .= "Latex cushions answer: {$_POST['latex']} \n\n"; $message .= "Window seat answer: {$_POST['cushion']} \n\n"; $message .= "Directions answer: {$_POST['directions']} \n\n"; $message .= "Competitors answer: {$_POST['competitors']} \n\n"; $message .= "Benefits answer: {$_POST['benefit']} \n\n"; $headers .= "From: {$_POST['email']}"; // GET FILE VARIABLES $tmpName = $_FILES['attachment']['tmp_name']; $fileType = $_FILES['attachment']['type']; $fileName = $_FILES['attachment']['name']; if (file($tmpName)) { // READING IN FILE BINARY $file = fopen($tmpName,'rb'); $data = fread($file,filesize($tmpName)); fclose($file); // A BOUNDARY STRING $randomVal = md5(time()); $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; // HEADER FOR FILE ATTACHMENT $headers .= "\nMIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed;\n" ; $headers .= " boundary=\"{$mimeBoundary}\""; // MULTIPART BOUNDARY ABOVE MESSAGE $message = "This is a multi-part message in MIME format.\n\n" . "--{$mimeBoundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // ENCODING FILE DATA $data = chunk_split(base64_encode($data)); // ADDING ATTACHMENT TO MESSAGE $message .= "--{$mimeBoundary}\n" . "Content-Type: {$fileType};\n" . " name=\"{$fileName}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mimeBoundary}--\n"; } $flgchk = mail ($recipient, $subject, $message, $headers); if($flgchk) { echo ('<p style="font-family: sans-serif; font-size: 1.2em; padding-top: 2em; text-align: center;">Thanks your application was sent successfully. You can now close this window.</p>'); } else { echo ('<p style="font-family: sans-serif; font-size: 1.2em; padding-top: 2em; text-align: center;">Sorry but there was an error sending your application, try emailing andrew@foamforcomfort.co.uk instead.</p>'); } ?>
  5. Hi guys, It's been a while since I coded in PHP (some 10 years or so). Now I need a web application and thought, I resource to my old talents but I think, I failed miserably :-) Here's the problem: I want the user to enter an item number and click a button to select the record from the products table. Once the - I call it "Getit" - button is clicked, the second form containing the record data should be rendered. So far, so good. However, although all variables show their correct values to render the second form, it just refuses to render. Right now, I have mental block and need some help, please. If you want to look at the app, here is the url : http://farbeyondrails.net/catalog/maintenance/edit_article.php Here is the code in question: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Maintenance</title> <link href="../layout.css" rel="stylesheet" type="text/css" media="all"> <link href="../styles.css" rel="stylesheet" type="text/css" media="all"> </head> <body> <?php require('../php/helper.php'); db_connect(); // Datenbank-Verbindung get_config(); $sql = ''; $arr_radio = array(); $arr_select = array(); $sql = "SELECT * FROM gauges"; $result = mysql_query($sql); if($result){ while ( $row = mysql_fetch_assoc ( $result ) ) { $i = $row['id']; $wert = $row['gauge']; $arr_radio[$i] = $wert; } $gauge_anz = count($arr_radio); } $sql = "SELECT * FROM categories"; $result = mysql_query($sql); if($result){ while($row = mysql_fetch_assoc($result)) { $i = $row['id']; $wert = $row['range']; $arr_select[$i] = $wert; } $sel_anz = count($arr_select); //echo $sel_anz.' Elemente in $sel_anz'; } echo ' <div id="wrapper"> <div id="header" <div id="fbr-logo"> <a href="http://farbeyondrails.net/" title="Back to home page"><img src="../'.$logo.'" /></a> </div> <!-- End fbr-logo --> <div id="header-grafik"> <img src="../'.$header_grafik.'" alt="FBR-Grafik" /> </div> <div id="fl-grafik"> <img src="../../tl_files/fbr/images/site/FL_logo.jpg" alt="FL-Logo"/> <img src="../../tl_files/fbr/images/site/roco_logo.jpg" alt="Roco-Logo"/> </div> </div> <div id="inhalt"> <div id="left" class="nav"> <h2>Navigation</h2> <ul> <li><a href="../index.php" title="Back to catalog">Front-End</a></li> <li><strong>--- System ---</strong></li> <li><a href="../admin/edit_config.php" title="Edit configuration">Configuration</a></li> <li><strong>--- Catalog ---</strong></li> <li><a href="cat_recalc.php" title="Re-calculate catalog with new values">Re-Calculate</a></li> <li><a href="new_prod.php" title="Add new products">Add new products</a></li> <li>Edit Catalog Item</li> <li><strong>--- Customers ---</strong></li> <li><strong>--- Orders ---</strong></li> <li><strong>--- Payments ---</strong></li> <li><strong>--- Shipments ---</strong></li> </ul> </div> <div id="main">'; echo ' <div class="center-title"><h1>Fleischmann / Roco Catalog - Maintenance</h1></div> <div class="center-title"><h2>Edit a specific catalog item</h2></div>'; // SQL - string // Test sql string echo 'SQL before main form: '.$sql.'<br/>'; echo ' Value isset($_POST["update"]) : '.isset($_POST['update']).'<br/>'; echo ' Value isset($_POST["submit"]) : '.isset($_POST['submit']).'<br/>'; if(!isset($_POST['update']) && isset($_POST['submit'])) { $sql = "SELECT * FROM products WHERE item_no='".$item_no."'"; $result = mysql_query($sql); if(result) { // Test echo '<br/>$result = '.$result.'<br/>'; $row = mysql_fetch_assoc($result); // Form for data record here if($item_no != 0 && $_POST['gesendet']) { echo ' <form method="POST" action="'.$PHP_SELF.'"> <table> <tr> <td>Item No.:</td><td><input type="text" name="item_no" size="6" value="'.$item_no.'" readonly="readonly" /> Brand : <input type="text" title="Enter the abbreviation for the brand" name="brand" size="2" maxlength="2" value="'.$row['brand'].'" /> Brand : <input type="text" title="Enter the abbreviation for availability:<br/> √ (ALT+2+5+1),N,L,D" name="avail" size="1" maxlength="1" value="'.$row['avail'].'"</td> </tr> <tr> <td>Gauge:</td><td>'; for($i=1;$i < $gauge_anz+1;$i++) { if($arr_radio[$i]==$row['scale']) { echo'<input type="radio" name="gauge" value = "'.$arr_radio[$i].'" checked="checked" />'.$arr_radio[$i].' '; }else{ echo'<input type="radio" name="gauge" value = "'.$arr_radio[$i].'"/>'.$arr_radio[$i].' '; } } echo '</td> </tr> <tr> <td><input type="hidden" name="gesendet" value="1" /><input type="submit" name="update" value="Update" /></td> </tr> </table> </form> '; }else{ } }else{ echo 'An error occured: '.mysql_error(); } } // Test echo '<br/>SQL string after click on Get IT:'.$sql.'<br/>'; echo 'Var_Dump $_POST: ';var_dump($_POST); if(!isset($POST['submit'])) { echo ' <form method="POST"> <p>Item No. : <input type="text" title="Enter the item number to be edited (max. 6 digits)" name="item_no" size="6" maxlength="6" value="0" /> <input type="submit" name="submit" onclick="$item_no=this.form.item_no.value" value="Get it!" /p> </form>'; } if(isset($_POST['item_no'])) { $item_no = $_POST['item-no']; $sql = "SELECT * FROM products WHERE item_no='".$item_no."'"; echo '<br/>'.$item_no; } // Footer echo '<div id="footer"> <div class="footer-text">©2014 Erhard Baltrusch, Far Beyond Rails,LLC, Florida, USA<br /> Pictures © Modelleisenbahn München Gmbh, München, Germany <br /> All Rights reserved </div> </div> </div> <div id="right" class="news-text"> <p> </p> </div> </div> </div>' ?> </body> </html> I'm pretty sure, I' missing just a tiny thing - just what I don't see ... Can someone please help me out? Thanks in advance Erhard
  6. hello guys just a quick question i have made a html form with php embedded. here is php code: how could i change the code if 1 of the inputs is'nt numeric then it would echo a message saying "insert numeric values" at the minute it echos that if all numeric values are entered. elseif(is_numeric($_POST['number1']) && is_numeric($_POST['number2']) && is_numeric($_POST['number3']) && is_numeric($_POST['number4'])){ echo "please insert number";
  7. Hi. I have made a application form for a job, I want the results the user enters into the boxes to come out into my database (evxhotel and the table apps). I get no errors and the website works perfectly fine but when I fill the form and submit the page just reloads and when I go to check my database I see that my results of the form are not in the database. I believe that maybe I put the mysql_connect and the mysql_select_db on the wrong lines. BTW, this is only the php script embedded into a html document. The file format and name is form.php. All the tags are correct. <?php $connect = mysql_connect("****", "****", "****") or die(mysql_error()); if(isset($_POST['submit'])){ $username = mysql_real_escape_string($_POST['Username']); $email = mysql_real_escape_string($_POST['Email']); $firstname = mysql_real_escape_string($_POST['First']); $lastname = mysql_real_escape_string($_POST['Last']); $day = mysql_real_escape_string($_POST['Day']); $month = mysql_real_escape_string($_POST['Month']); $year = mysql_real_escape_string($_POST['Year']); $time = mysql_real_escape_string($_POST['Time']); $position = mysql_real_escape_string($_POST['Position']); $why = mysql_real_escape_string($_POST['Why']); $what = mysql_real_escape_string($_POST['What']); $exp = mysql_real_escape_string($_POST['Exp']); $hours = mysql_real_escape_string($_POST['Hours']); $comments = mysql_real_escape_string($_POST['Comments']); mysql_select_db($connect, "evxhotel") or die(mysql_error()); $sql = mysql_query ("INSERT INTO apps (username, email, realname, dob, time, position, why, what, exp, hours, comments) VALUES ('".$username."', '".$email."', '".$firstname/$lastname."', '".$day/$month/$year."', '".$time."', '".$position."', '".$why."', '".$what."', '".$exp."', '".$hours.", '".$comments."')", $connect); if($sql) { echo "Your applicaton has been added to the database."; } else { die(mysql_error()); } } ?> Whats wrong? Thanks in advance.
  8. I've been trying to work on a form in PHP. I've got it all set up and submitting but the only problem is that I try to display the data back on the page for testing purposes but every time I hit submit, it empties the form with no results. I've written my code as follows: <!DOCTYPE html> <head> <link rel="stylesheet" type="text/css" href="styling.css"> </head> <body> <form action="registerplayer.php" action="POST"> <p>First Name:<input type='text' name='firstName'></p> <p>Last Name:<input type='text' name='lastName'></p> <p>Username:<input type='text' name='username'></p> <p>Password:<input type='text' name='password'></p> <p><input type='submit' value='Submit'></p> </form> <?php if(isset($_POST["firttName"]) && isset($_POST["lastName"]) && isset($_POST["username"]) && isset($_POST["password"])) { $firstname = $_POST["firstName"]; $lastname = $_POST["lastName"]; $username = $_POST["username"]; $password = $_POST["password"]; echo "<p>Name: " . $firstname . " " . $lastname . "\nUsername: " . $username . "\nPassword: " . $password . "</p>"; } ?> </body></html> Anyone know what I'm not seeing here? I've been working on this for a while now.
  9. i designed a form with a php send via email. what i cant figure out is how to collect the info from the checkboxes and put in the php this is the check box: <td id="td_element_field_0" style=""><div style="width:100%;padding-bottom:5px;"><input id="element_0_0" name="element_0[]" value="Health" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Health </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_1" name="element_0[]" value="Finances" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Finances </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_2" name="element_0[]" value="Family" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Family </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_3" name="element_0[]" value="Personal Dreams, Goals & Visions" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Personal Dreams,Goals & Visions </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_4" name="element_0[]" value="Restoration" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Restoration </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_5" name="element_0[]" value="Special Unspoken Request" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Special Unspoken Request </font></div><div style="clear:both;"></div><div style="padding-bottom:8px;color:#000000;"><small><font face="Verdana"></font></small></div> this is the php <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "support@higherpowercomputers.com"; $email_subject = "Prayer Request or Praise Report"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['prayer_praise'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $prayer_praise = $_POST['prayer_praise']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($prayer_praise) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Phone Number: ".clean_string($phone_number)."\n"; $email_message .= "Email: ".clean_string($email)."\n"; $email_message .= "Subject: ".clean_string($subject)."\n"; $email_message .= "Prayer and or Praise Report: ".clean_string($prayer_praise)."\n"; // create email headers $headers = 'From: '.$email."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> echo "<script>window.location = 'http://www.higherpowercomputers.com/faith//thank_you.html'</script>"; <?php } ?>
  10. Hey, I have created a contact us form which works nicely with my site, however I have some backup PHP validation code, which all works apart from the last name section, how can I set it up to it checks to see if there is a first name and a last, maybe even another name? This is what I have so far and it only works if you put in a first name and nothing else: $string_exp = "/^[A-Za-z.'-]+\$/"; if(!preg_match($string_exp, $name)) { $error_message .= 'The Name you entered does not appear to be valid.<br/>'; } Thank you
  11. I have a Ultimate Web Hosting Linux account with Godaddy. I am using the pre-built webform godaddy provides which is the gdform.php. The form works the only problem I wanted to add a file upload and this form does not support it. I need help making a customize form. I have tried to add to the form and still not receiving the file. html code <form action="/gdform.php" method="post"> <h1>Your Information</h1> <input type="hidden" name="subject" value="Form Submission" <input type="hidden" name="redirect" value="thankyou.html" /> <a href="https://cid-31240a340806bd09.calendar.live.com/calendar/private/65823f73-7ada-4c07-ad10-7f2023657d03/392aa04c-6892-452d-986b-b5cd70bed1a7/index.html" target="_blank" >View Appointment Calendar</a><br> <img src="kelly3.jpg" alt="lace front wig" class="kelly3"> <p>First Name <input type="text" name="first_name" size="40" maxlength="35" /></br</p> <p>Last Name <input type="text" name="last_name" size="40" maxlength="35" /></br></p> <p>Email <input type="email" name="email" size="40" maxlength="35" required /></br></p> <p>Telephone<input type="tel" name="tel" size="40" maxlength="35"/></br></p> <p>Please provide information on the hair services you are interested in.</p> <textarea name="info" cols="40" rows="10"> </textarea><br> <form enctype="multipart/form-data"> <p>Please upload your hair style photos</p><input type="file" name="file" accept="image/jpg,image/gif,image/png"> <input type="submit" name="submit" value="submit" style="background-color: #f00;font-size:24px; margin-top: 60px; margin-left: 415px; "/> </form> </form> php code <?php $request_method = $_SERVER["REQUEST_METHOD"]; if($request_method == "GET"){ $query_vars = $_GET; } elseif ($request_method == "POST"){ $query_vars = $_POST; } reset($query_vars); $t = date("U"); $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t; $fp = fopen($file,"w"); while (list ($key, $val) = each ($query_vars)) { fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n"); fputs($fp,"$val\n"); fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n"); if ($key == "redirect") { $landing_page = $val;} } fclose($fp); $allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/x-png") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < 20000) && in_array($extension, $allowedExts)) if ($landing_page != "thankyou.html"){ header("Location:thankyou.html"); } else { header("Location: http://".$_SERVER["HTTP_HOST"]."thankyou.html"); } ?> I receive an email with just a name of the attachment. If you guy's can give me a whole another php code that could work it would be appreciated.
  12. Hi guys, I'm having a hard time displaying the quantity the user selects in my index.php to reflect that same exact quantity in my invoice.php page. Please help! Any suggestions will be greatly appreciated:) my product information is stored in a file called products_info.inc and looks something like this: $hulkhamburger = array('Product' => 'Hulk Hamburger', 'Description' => '<img src="hamburger.jpg" "height=100" "width=100">', 'Price' => '$1.00', 'Quantity' => "<input type='text' name='quantity[]'>"); $atomichotdog = array('Product' => 'Atomic Hot Dog', 'Description' => '<img src="hotdog.jpg" "height=100" "width=100">', 'Price' => '$2.00', 'Quantity' => "<input type='text' name='quantity2[]>"); $friedchicken = array('Product' => 'Fantastic 4 Fried Chicken', 'Description' => '<img src="friedchicken.jpg" "height=100" "width=100">', 'Price' => '$3.00', 'Quantity' => "<input type='text' name='quantity[]'>"); $psyonicpizza = array('Product' => 'Psyonic Pizza', 'Description' => '<img src="pizza.jpg" "height=100" "width=100">', 'Price' => '$4.00', 'Quantity' => "<input type='text' name='quantity[]'>"); $marvelmeatloaf = array('Product' => 'Marvel Meatloaf', 'Description' => '<img src="meatloaf.jpg" "height=100" "width=100">', 'Price' => '$5.00', 'Quantity' => "<input type='text' name='quantity[]'>"); //The following array takes our previous five arrays and puts them into one array for easier coding and reading. $allfood = array ($hulkhamburger, $atomichotdog, $friedchicken, $psyonicpizza, $marvelmeatloaf); Now my index.php looks like this: <?php //Include products info.inc (Which holds all our product arrays and info) //Credit: Tracy & Mark (Thank you!) include 'products_info.inc'; /*The following code centers the table on the page, makes the table background white, makes the table 50% of the browser window, gives it a border of 1 px, gives a padding of 2 px between the cell border and content, and gives 1 px of spacing between cells. */ echo "<table align=center bgcolor='FFFFFF' width=50% border=1 cellpadding=1 cellspacing=2>"; //Credit: Tracy & Mark (Thank you!) echo '<th>Product</th> <th>Description</th> <th>Price</th> <th>Quantity</th>'; //The following code loops through the whole table body and then prints each row. for($i=0; $i<count($allfood); $i++) { //Credit: Tracy & Mark (Thank you!) echo "<tr align=center>"; echo "<td>{$allfood[$i]['Product']}</td>"; echo "<td>{$allfood[$i]['Description']}</td>"; echo "<td>{$allfood[$i]['Price']}</td>"; echo "<td>{$allfood[$i]['Quantity']}</td>"; echo "</tr>"; } //This code ends the table. echo "</table>"; echo "<br>"; ?> The problem arises when I enter any quantity in my index after pressing submit, it goes to this following invoice.php and does not display the quantity that was inputed from the index <?php //Include products info.inc (Which holds all our product arrays and info) //Credit: Tracy & Mark (Thank you!) require 'products_info.inc'; //Display the invoice & 'WELCOME USER. THANK YOU FOR USING THIS DAMN THING msg' /*The following code centers my invoice table on the page, makes the table background white, makes the table 50% of the browser window, gives it a border of 1 px, gives a padding of 2 px between the cell border and content, and gives 1 px of spacing between cells. */ echo "<table align=center bgcolor='FFFFFF' width=50% border=1 cellpadding=1cellspacing=2>"; echo "<tr>"; echo "<td align=center><b>Product</b></td>"; echo "<td align=center><b>Quantity</b></td>"; echo "<td align=center><b>Price</></td>"; echo "<td align=center><b>Extended Price</b></td>"; echo "</tr>"; for($i=0; $i<count($allfood); $i++) { //Credit: Tracy & Mark (Thank you!) $qty= @$_POST['quantity']['$i']; // This calculates the price if the user orders more than 1 item. $extendedprice = $qty*$allfood[$i]['Price']; echo "<tr>"; echo "<td align=center>{$allfood[$i]['Product']}</td>"; echo "<td align=center>$extendedprice</td>"; echo "<td align=center>{$allfood[$i]['Price']}</td>"; echo "</tr>"; } // The goal here was to make it so that if the user selected a certain quantity from index.php, it would carry over and display on the invoice.php if ($qty == 0) { $quantityErr = "<BR><span style='color:red'>Please go back and input a quantity.</spand></BR>"; } elseif ($qty > 0) { echo $qty; } /*echo "<tr>"; echo "<td align=center>Subtotal</b></td>"; echo "<td align=center></td>"; echo "<td align=center></td>"; echo "<tr>"; echo "<td align=center>Tax at 5.75%</td>"; echo "<td align=center></td>"; echo "<td align=center></td>"; echo "<tr>"; echo "<td align=center><b>Grand total</b></td>"; echo "<td align=center></td>"; echo "<td align=center></td>"; */ echo "</table>"; ?> I bolded the items that might be of question, but then again, I'm new to PHP:( Thank you in advance folks!
  13. hi, ive just started learning php and sql yesterday. im building a timesheets webpage for employees i want to know how to join the 'totalhours' to "totalminutes' and then put it in the query as one value? eg the databse will store 5.25 or 3.75 etc. the employees will type an hour (eg 5 or 3 ) and then click a radio button that says 15mins or 45mins here is the code so far: PHP $sql="INSERT INTO Persons (notes, starttime, date, finishtime, totalhours, company, breaktime) VALUES ('$_POST[notes]','$_POST[starttime]','$_POST[date]','$_POST[finishtime]','$_POST[totalhours]', '$_POST[comp]','$_POST[breaktime]')"; HTML <form action="submittimesheet.php" method="post"> company<input type="text" name="comp"><br> date<input type="date" name="date"><br> start time <input type="time" name="starttime"> finish time <input type="time" name="finishtime"><br> total break time<input type="text" name="breaktime"><br> total hours worked<input type="text" name="totalhours">(number from 1-10)<br> total minutes worked: <br> <input type="radio" value="0" name="totalminutes">0<br> <input type="radio" value="25" name="totalminutes">15<br> <input type="radio" value="50" name="totalminutes">30<br> <input type="radio" value="75" name="totalminutes">45<br> notes<input type="text" name="notes" style="height: 50px;"><br> <input type="submit">
  14. I have the following php form sending my info to an email address I have 2 problems 1. its not sending the correctly Form details below. Company Name: HigherPower First Name: James Last Name: Peters Email: Telephone: 7708961481 Address: City: State: Zip Code: 2. I have checkboxes where someone can check however many videos they would like to rent from the company video selection. how do I do that <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "support@higherpowercomputers.com"; $email_subject = "Video Rental Form"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if( !isset($_POST['company_name']) || !isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['telephone']) || !isset($_POST['email'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $company_name = $_POST['company_name']; // required $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $telephone = $_POST['telephone']; // required $email_from = $_POST['email']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$company_name)) { $error_message .= 'The Company Name you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Company Name: ".clean_string($company_name)."\n"; $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "State: ".clean_string($state)."\n"; $email_message .= "Zip Code: ".clean_string($zip_code)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?>
  15. Hi, In a form I am adding "1278|Toyname" as a value in a drop down. This way if they select a certain toy, I can have the ID and the toy name they are referring too. I would like to post this info in my contact form and I would like to separate via the | (Pipe) and store the id "1278" in a field called id and "Toyname" in a field named toy when the form is posted. I know I have to use the explode function to seperate but I dont even know where to begin. Thank you in advance, Bill
  16. Hi php Freaks XD I have a small problem. I have a form that i would like to make it so i can add a column to my table on my site. but the form that fills our the stuff, when i press the submit button i don't get a response. Here is a rly simple code that i can't get to work. When i press the button it should say "success", and if the textbox is empty it should say "error". simple right? Well i can't get any response what so ever. here is the code in simpel. if(isset($_POST['addTableBtn'])){ if(empty($_POST['addTableText'])){ echo "Error"; }else{ echo "Success"; } } and the submit button name and textbox name match, i have checket.
  17. Hi guys, I have question. Im trying to write some text editor with bbcodes etc. I need to add some textbox in which i could add url to item (http://mfo3.pl/game/view.php?t=a&id=20) and after clicking "add" button it will add to textarea contents of div with class=icon some ideas?
  18. Could someone possibly let me know how they would go about doing the following: The Process: An anonymous user goes to a product page and clicks the link "View product datasheet". This link will redirect them to a form. They fill out the form and submit. Once submitted a 2 month cookie is stored in their browser. They will be redirected to the "Secret" page with all of the links to all product datasheets listed. For 2 months if they go to any products on the site and click "View product datasheet", they won't be bothered with the form. ONE RULE: Anonymous users cannot access the "Secret" page unless the cookie is stored in their browser.
  19. Hi guys i made a form with just 6 fields but im having trouble creating a php file to send the forms to my email. Please help, here's the html code for the form. <form name="form1" method="post" action="http:www.bpwebdesign.co.za/formmail.php"> <p id="Company Name"><span id="CompanyTextField"> <input type="text" name="Company Name" id="Company Name"> </span> <label for="Company Name"></label> Company Name</p> <p><span id="NameTextField"> <label for="Name4"></label> <input type="text" name="Name" id="Name4"> <span class="textfieldRequiredMsg">Your Name.</span></span></p> <p id="Phone Number"><span id="PhoneNumberTextField"> <input type="text" name="Phone Number" id="Phone Number"> </span> <label for="Phone Number"></label> Phone Number</p> <p><span id="EmailTextField"> <input type="text" name="Email" id="Email"> </span> <label id="Email"> Your Email<br> <br> You Have Chosen the starter package (10 Emails)</label></p> <p> <label for="How to Pay"></label> <select name="How to Pay" size="1" id="How to Pay"> <option>Per Month R20</option> <option>Quataly (Once in 3 months) R60</option> <option>Annual (12 Months) R240</option> </select> How would you like to pay? </p> <p> <input type="submit" name="Submit" id="Submit" value="Submit"> </p> <p> </p> </form>
  20. Hey folks! I hope that I posted this in the right section. For some time now, I've been wanting to know how to have HTML form fields of the same form appear/disappear depending on the value of one of the fields in that form itself. Will this require JavaScript? Am I trying to step into something too complex? Here's an example of what I'm trying to learn about: There is a form, which at first displays only a drop-down box with values from "1-5". If the user selects "2", two text fields will appear below the drop-down box. If the user then selects "1", the two fields become one. If "5" is selected, the total number of fields visible will be five. The five fields available will belong to the same form, and overall, there will be only five text fields present (not 1+2+3+4+5=15). Does anyone know how I could achieve this? I just want to get an idea of how to get this done. I hope that I didn't sound confusing. I will appreciate any help offered, and I thank you for reading! Thanks and Regards, Thauwa.
  21. Hey guys, As you can see i have a form im trying to use for a user to change or update their profile settings. i know in using php / mysql you can set the default value in the forms for say names and email and what not. is there a way to do that for check boxes and buttons ? if you see my form below, i have added in the php logic for the first code. i just am confused as to a way to set all the fields to having a default. i figure this is the easiest way to not have to write a whole bunch of conditionals to make sure if a person doesnt input a value in the update fields, it will just make the field in the database blank as well. i figure i rather have them just re-input the data back that will just show up as the default anyway. thanks guys <tbody><tr> <td class="register_td_left"><span class="">Email Address:</span></td> <td class="register_td_right" colspan="2"><input type="email" name="update_email" size="35" maxlength="50" value="<? echo $user_data['email']; ?>"></td> // HERE I ADDED PHP, TO GRAB FROM MYSQL </tr> <tr> <td class="register_td_left"></td><td class="extra_data2" colspan="2"> </td> </tr> <td class="register_td_left"><span class="">Gender:</span></td> <td class="register_td_right" colspan="2"> <input id="male" name="gender" type="radio" value="m"><label for="male"> Male</label> <input id="female" name="gender" type="radio" value="f"><label for="female"> Female</label> </td> <tr> <td class="register_td_left"></td><td class="extra_data2" colspan="2"> </td> </tr> <tr> <td class="register_td_left"><span class="">Date of Birth:</span></td> <td class="register_td_right" colspan="2"><select name="month" id="month" style="width:100px"><option value="">---</option><option value="1">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select><select name="date" id="date" style="width:45px"><option value="">---</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="year" id="reg-year" style="width:60px"><option value="">---</option><option value="2016">2016</option><option value="2015">2015</option><option value="2014">2014</option><option value="2013">2013</option><option value="2012">2012</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</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><option value="1899">1899</option><option value="1898">1898</option><option value="1897">1897</option><option value="1896">1896</option></select></td> </tr>
  22. I have a select box that filters categories. However, there are also sub-categories, and sub-sub-categories, etc. <form method="GET" action="categories.php"> <div class="form"> <select id="filter" size="1" name="filterCat"> <option value="allCats" <?php if ($filterCat == 'allCats') echo 'selected="selected"';?>>All Categories</option> <option value="0" <?php if ($filterCat == 0) echo 'selected="selected"';?>>MAIN</option> <option value="noItem" disabled="disabled" >-------------------------------</option> <?php $cat_result = mysql_query("SELECT `categories_id`,`categories_name` FROM `categories` WHERE `parent_id`=0 ORDER BY `categories_name`"); while($cat_row = mysql_fetch_assoc($cat_result)){ $categories_id = $cat_row['categories_id'] ?> <option value="<?php echo $categories_id; ?>" <?php if ($filterCat == $categories_id) echo 'selected="selected"';?>> <?php echo $cat_row['categories_name']; ?></option> <?php $cat_result2 = mysql_query("SELECT `categories_id`,`categories_name` FROM `categories` WHERE `parent_id`=$categories_id ORDER BY `categories_name`"); while($cat_row2 = mysql_fetch_assoc($cat_result2)){ $categories_id2 = $cat_row2['categories_id'] ?> <option value="<?php echo $categories_id2; ?>" <?php if ($filterCat == $categories_id2) echo 'selected="selected"';?>> - <?php echo $cat_row2['categories_name']; ?></option> <?php $cat_result3 = mysql_query("SELECT `categories_id`,`categories_name` FROM `categories` WHERE `parent_id`=$categories_id2 ORDER BY `categories_name`"); while($cat_row3 = mysql_fetch_assoc($cat_result3)){ $categories_id3 = $cat_row3['categories_id'] ?> <option value="<?php echo $categories_id3; ?>" <?php if ($filterCat == $categories_id3) echo 'selected="selected"';?>> -- <?php echo $cat_row3['categories_name']; ?></option> <?php $cat_result3 = mysql_query("SELECT `categories_id`,`categories_name` FROM `categories` WHERE `parent_id`=$categories_id3 ORDER BY `categories_name`"); while($cat_row4 = mysql_fetch_assoc($cat_row4)){ $categories_id4 = $cat_row4['categories_id'] ?> <option value="<?php echo $categories_id4; ?>" <?php if ($filterCat == $categories_id4) echo 'selected="selected"';?>> -- <?php echo $cat_row4['categories_name']; ?></option> <?php }}}} ?> </select> </div> </form> So my issue is that I repeat the code for each new sub-category, and create a new loop to look up the sub-categories belonging to that one. Is there a simpler way that will cause the categories to look up if they have any sub-categories, and then run a loop from there, i.e. infinitely, so that if there were even 10 levels of categories, it would still be able to find them all?
  23. I need to make part of my form auto-populate calculated values based on user input. Here is what I have so far: The HTML <div class="PaymentDetails"> <fieldset> <legend>Payment Details</legend> Ad Charge $ <input type="number" name="AdPrice" id="AdPrice" class="medium" value="" /><br /> Color Charge + <input type="number" name="ColorCharge" id="ColorCharge" class="medium" value="" /><br /> Web Ad + <input type="number" name="WebAd" id="WebAd" class="medium" value="" /><br /> Subtotal = <input type="number" name="AdSubtotal" id="AdSubtotal" class="medium" value=<? $SubTotal ?> /><br /> Down Payment - <input type="number" name="DownPayment" id="DownPayment" class="medium" value="" /><br /> Total = <input type="number" name="TotalPrice" id="TotalPrice" class="medium" value=<? $TotalPrice ?> /><br /><br /> # Consec. Payments \ <input type="number" name="Payments" id="Payments" class="medium" value="" /><br /> Amt Each Payment $ <input type="number" name="Payment" id="Payment" class="medium" value=<? $Payment ?> /><br /><br /> <input type="checkbox" name="ProratedCheck" id="ProratedCheck" /><label>Prorated/Length</label><input type="text" name="ProratedLength" id="ProratedLength" /> </fieldset> </div> The PHP <? $AdPrice = $_POST['AdPrice']; $ColorCharge = $_POST['ColorCharge']; $WebAd = $_POST['WebAd'] + $Number; $SubTotal = $AdPrice + $ColorCharge + $WebAd; $DownPayment = $_POST['DownPayment']; $TotalPrice = $SubTotal - $DownPayment; $Payments = $_POST['Payments']; $Payment = $TotalPrice / $Payments; ?> I know that i'm probably missing a fairly big concept here... for instance: How does the code know that a number has been entered and that a number needs to be output? Warning: Division by zero <--- i'm getting this error message also... Thank you for any help or guidance you can give!
  24. Hello- Based on the suggestion by another member, I am reposting my problem. Here is my question- How do you create a form in PHP where the results entered in from the user will be generated in a table? When I test the pages, I only get the start of the table, key and results(values) fields but no values! (Currently it looks like this). Visually, it should look like this if it works correctly: What am I missing from my code? order form.php results form.php
  25. Hey, Im new to PHP and am trying to make a simple form where it puts the form data into a table called "users" This is the form: <p><form method="post" action="register.php"> <table border="0" align="center"> <tr> <td>Username</td><td><input type="text" name="username" size="15" > </tr> <br /> <tr> <td>Password</td><td><input name="password" type="password" size="15"></td> </tr> <br /> <td><input type="submit" value="Sign Up"/></td><td></td> </table> This is the php code: <?php $dbhost = ''; $dbname = ''; $dbuser = ''; $dbpass = ''; mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname); $order = "INSERT INTO users (username, password) VALUES ('$username', '$password')"; $result = mysql_query($order); if($result){ echo("<br>It Worked!"); } else{ echo("<br>It Failed!"); } ?> But when i upload it to the server and try it, it says there was a entry but its blank..... When i upload it to a server and try it, it automaticly seems to post the data to the database before i even enter a username/password! when i type a username/password in and post it again it says there was another entry but its blank..... any help? - Thanks!
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.