Jump to content

Search the Community

Showing results for tags 'form'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I'm making my own CMS for my company so going through making the pages for the back end. What I want to do that I'm stuck on is -------------- I want to allow the user to specify how many input text fields they want shown on the page. I'm thinking that they could write a number then click submit, send the data to the same page (PHP self or action blank) and then the required amount of input fields would be echoed out. Echoing out is easy, I want to know how to find out how many fields are required, and then process it. Thanks in advance.
  2. Hello everyone! I would like to need some help from someone who understands the basics of PHP. About the problem: I am supposed to make the user's input number multiple (a number between 0 and 10) with the text string the user has written. For example, the user writes "Hello" and "5", "Hello" should be printed out five times. I must use a for-loop and a while-loop to solve it.) Maybe it has to do with something called parameter. Would be thankful for some help! This is my current code: <form method="POST"> Message: <input type="text" name="message"/> Number: <input type="text" name="number"/> <input type="submit" value="OK!" name="submit" /> </form> <?php if(isset( $_POST["submit"] ) ) { $message = $_POST["message"]; $number = $_POST["number"]; ?> <?php for ($random = 0; $random < 10; $random = $random + $number) { echo "<ul><li>$message</li></ul>"; } ?> <?php } ?>
  3. So here's the situation. 1. I retrive records form mysql database. WORKS. 2. Within each record, I load a "form" via on click .button. WORKS. 3. The form is basically a way for a User to send a message to that record specifically. WORKS That process works. What doesn't work is that every time I submit a form to the database, it will not insert the "message" field text(appears empty) and the "record_id" will insert but it'll be same for all records inserted, no matter how many different records forms I submit. Other data like "message-to" and "message-by" insert fine. Here is the full page setup. Also, session_start(); is in the init.php <?php require_once 'core/init.php'; $user = new User(); $mainUserid = escape($user->data()->user_id); ?> <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title><?php echo $title; ?></title> <meta name="description" content="<?php echo $description; ?>"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <link rel="stylesheet" href="css/style.css" media="screen"> </head> <body> $getRecord = $db->prepare("SELECT records.*, users.* FROM records LEFT JOIN users ON records.user_id = users.user_id ORDER BY record_id DESC LIMIT 10"); $getRecord->execute(); $resultRecord = $getRecord->fetchAll(PDO::FETCH_ASSOC); if(count($resultRecord) < 1) { $error = '0 records found.'; } else { foreach($resultRecord as $row) { $record_id = escape(intval($row['record_id'])); $user_id = escape(intval($row['user_id'])); $username = escape($row['full_name']); $title = escape($row['title']); $details = escape($row['details']); $_SESSION['record-id'] = $record_id; $_SESSION['message-to'] = $user_id; $_SESSION['message-by'] = $mainUserid; $message = Input::get('message'); // HTTP method POST or GET $_SESSION['message'] = $message; ?> <div class="record"> <h1><?php echo $title; ?></h1> <p><?php echo $details; ?></p> <p><?php echo $user_id; ?></p> <button class="button">send message</button> <!-- this form loads through on click(.button) function and is located in "ajax/form.php" --> <form class="new-form"> <textarea name="message" class="message">Enter message</textarea> <input type="button" name="submit" class="form-submit" value="Send Message"> </form> </div> <?php } } <!-- js scripts below --> <script src="js/jquery-1.11.0.min.js"></script> <script> $(document).ready(function(){ $(".button").click(function(){ $(this).parent().load("ajax/form.php"); }); }); </script> <script> $(document).on('click','.form-submit',function() { if($(".message").val()==='') { alert("Please write a message."); return false; } $(".form-submit").hide(); //hide submit button var myData = 'message='+ $(".message").val(); //build a post data structure jQuery.ajax({ type: "POST", // HTTP method POST or GET url: "process.php", //Where to make Ajax calls dataType:"text", // Data type, HTML, json etc. data:myData, //Form variables success:function(response){ $(".message").val(''); //empty text field on successful $(".form-submit").show(); //show submit button }, error:function (xhr, ajaxOptions, thrownError){ $(".form-submit").show(); //show submit button alert(thrownError); } }); }); </script> </body> </html> here is process.php <?php require_once 'core/init.php'; $session_record_id = $_SESSION['record-id']; $session_message_to = $_SESSION['message-to']; $session_message_by = $_SESSION['message-by']; $session_message = $_SESSION['message']; $insertMssg = $db->prepare("INSERT INTO sub_records(record_id, message_to, message_by, message, bid_posted) VALUES(:record_id, :message_to, :message_by, :message)"); $insertMssg->bindParam(':record_id', $session_record_id); $insertMssg->bindParam(':message_to', $session_message_to); $insertMssg->bindParam(':message_by', $session_message_by); $insertMssg->bindParam(':message', $session_message); $resultInsert = $insertMssg->execute(); if($resultInsert == false) { $error = 'Your message could not be inserted.'; } else { $success = 'Your message has been added.'; } ?> <div class="success"><?php echo $success; ?></div> <div class="error"><?php echo $error; ?></div>
  4. I am trying to create a dynamic form using Jquery but don't know how to post those data using $_POST. The page <html> <head> <title> Dynamically create input fields- jQuery </title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(function() { var addDiv = $('#addinput'); var i = $('#addinput p').size() + 1; $('#addNew').live('click', function() { $('<p><input type="text" id="p_new" size="40" name="p_new_' + i +'" value="" placeholder="I am New" /><input type="text" id="p_new2" size="40" name="p_new_2' + i +'" value="" placeholder="I am New 2" /><a href="#" id="remNew">Remove</a> </p>').appendTo(addDiv); i++; return false; }); $('#remNew').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> </head> <body> <h2>Dynammically Add Another Input Box</h2> <form action="gen.php" method="post"> <div id="addinput"> <p> <input type="text" id="p_new" size="40" name="p_new" value="" placeholder="Input Value" /><input type="text" id="p_new2" size="40" name="p_new2" value="" placeholder="Input Value" /><a href="#" id="addNew">Add</a> </p> </div> </form> </body> </html> Here is live example.. A Pen by Captain Anonymous Whatever, The new fields got an unique name="" value as p_new_1, p_new_21 for first new field, p_new_2, p_new_22 for second new field ...... ...... Now, I know I can display inserted data using <?php echo $_POST["p_new_1"]; ?> and similar way like this... But as a growing field, this form can have unlimited input field. How can I display all of those data in the page gen.php? It must be something like this example: <html> <body> <div class="header">Generated content<div> <p><a href="inserted data of first field of default row">inserted data of second field of default row</a></p> <p><a href="inserted data of first field of first new row">inserted data of second field of first new row</a></p> <p><a href="inserted data of first field of 2nd new row">inserted data of second field of 2nd new row</a></p> <p><a href="inserted data of first field of 3rd new row">inserted data of second field of 3rd new row</a></p> <p><a href="inserted data of first field of 4th new row">inserted data of second field of 4th new row</a></p> And list go on according to submitted form.... </div></body></html> I actually lake of knowledge of PHP and no idea about array or something named loop. Can someone do it for me? What I have to do in gen.php?
  5. I am reading images from the directory 'images' which contains several folders with images. I want to show every image in a div and with the checkbox to decide if it is fashion or not fashion. I am using the following code in order to read files from directory and showing them in browser. The divs is one after other: <?php function listFolderFiles($dir){ $html = ''; // Init the session if it did not start yet if(session_id() == '') session_start(); $html .= '<ol>'; foreach(new DirectoryIterator($dir) as $folder){ if(!$folder->isDot()){ if($folder->isDir()){ // $html .= '<li>'; $user = $dir . '/' . $folder; foreach (new DirectoryIterator($user) as $file) { if($file != '.' && $file != '..'){ $image = $user . '/' . $file; // Check the pictures URLs in the session if(isset($_SESSION['pictures']) && is_array($_SESSION['pictures'])){ // Check if this image was already served if(in_array($image, $_SESSION['pictures'])){ // Skip this image continue; } } else { // Create the session variable $_SESSION['pictures'] = array(); } // Add this image URL to the session $_SESSION['pictures'][] = $image; // Build the form //echo $image, "</br>"; $html .= ' <style> form{ font-size: 150%; font-family: "Courier New", Monospace; display: inline-block; align: middle; text-align: center; font-weight: bold; } </style> <form class = "form" action="' . action($image) . '" method="post"> <div> <img src="' . $image . '" alt="" /> </div> <label for="C1">FASHION</label> <input id="fashion" type="radio" name="fashion" id="C1" value="fashion" /> <label for="C2"> NON FASHION </label> <input id="nfashion" type="radio" name="nfashion" id="C2" value="nfashion" /> <input type="submit" value="submit" /> </form>'; // Show one image at a time // Break the loop break 2; } } // $html .= '</li>'; } } } $html .= '</ol>'; return $html; } //##### Action function function action($img){ $myfile = fopen("annotation.txt", "a"); if (isset($_POST['fashion'])) { fwrite($myfile, $img." -- fashion\n"); // echo '<br />' . 'fashion image'; } else{ fwrite($myfile, $img." -- nonFashion\n"); // echo '<br />' . ' The submit button was pressed<br />'; } } echo listFolderFiles('images//'); ?> When I make call of action($image) from inside form tag, I noticed, that a default value of submit it is parsed to the function, thus it stores the name of the image with the default value and the chosen value for the first image it is parsed to the second image, the chosen value of the second image it is stored to the file with the third image and so on. When I make call in side input submit tag it began storing to the file from the second image with the value of the first one and so on. I couldn't manage to have stored to the file the correct correspondence between the image and the chosen value. Where should I make call of the action function in order to do it properly?
  6. I understand that is might be something that is already answered and I apologize if it is, I could not find it. What I need to do is build a simple form that has two options, they will be dropdown options. Dropdown A and Dropdown B then a Submit button. This part I understand in HTML, although it may be easier in php or javascript. Then I need it to take the two options and create a "if/then" statement that loads a specific pdf that matches the two options selected. Example. If someone selects Option 1 from Dropdown A and Option 2 From Dropdown B then it loads 12.pdf If someone selects Option 5 from Dropdown A and Option 3 From Dropdown B then it loads 53.pdf If someone selects Option 2 from Dropdown A and Option 1 From Dropdown B then it loads 21.pdf and so on... It does not have to be the exact thing just some way to take both inputs and have it equal a specific pdf. Here is the form I built but I don't know what to put in the form_action.php file in order to make it work <!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> <center> <h1> Get Directions</h1> <form action="form_action.php" method="get" name="directions" target="_new"> <select name="startpoint" size="1"> <option value="north">North Tower Entrance</option> <option value="south">South Tower Entrance</option> <option value="moba">MOB A Entrance</option></select> -----> <select name="endpoint" size="1"> <option value="onco">Oncology</option> <option value="radio">Radiology</option> <option value="pulm">Pulmanary</option></select> <br /><br /> <input type="submit" value="Submit" /> </form> </center> </body> </html> Any help is appreciated, thanks.
  7. I am quite inexperienced when it comes to coding and I obtained a template for an online form submission that I butchered to meet my needs. Our clients are attempting to send the form, and there are times that it transmits correctly, and times that it won't. There is verification code to try and eliminate bots from filing and submitting bogus forms. Can anyone spend the time to review my code and attempt to tell you where my issue may lie? You may view my form at http://www.damageana.com/new_assignment.php <?php session_start(); function getRealIp() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } function writeLog($where) { $ip = getRealIp(); // Get the IP from superglobal $host = gethostbyaddr($ip); // Try to locate the host of the attack $date = date("d M Y"); // create a logging message with php heredoc syntax $logging = <<<LOG \n << Start of Message >> There was a hacking attempt on your form. \n Date of Attack: {$date} IP-Adress: {$ip} \n Host of Attacker: {$host} Point of Attack: {$where} << End of Message >> LOG; // Awkward but LOG must be flush left // open log file if($handle = fopen('hacklog.log', 'a')) { fputs($handle, $logging); // write the Data to file fclose($handle); // close the file } else { // if first method is not working, for example because of wrong file permissions, email the data $to = 'aserio@damageana.com'; $subject = 'HACK ATTEMPT'; $header = 'From: aserio@damageana.com'; if (mail($to, $subject, $logging, $header)) { echo "Sent notice to admin."; } } } function verifyFormToken($form) { // check if a session is started and a token is transmitted, if not return an error if(!isset($_SESSION[$form.'_token'])) { return false; } // check if the form is sent with token in it if(!isset($_POST['token'])) { return false; } // compare the tokens against each other if they are still the same if ($_SESSION[$form.'_token'] !== $_POST['token']) { return false; } return true; } function generateFormToken($form) { // generate a token from an unique value, took from microtime, you can also use salt-values, other crypting methods... $token = md5(uniqid(microtime(), true)); // Write the generated token to the session variable to check it against the hidden field when the form is sent $_SESSION[$form.'_token'] = $token; return $token; } // VERIFY LEGITIMACY OF TOKEN if (verifyFormToken('form1')) { // CHECK TO SEE IF THIS IS A MAIL POST if (isset($_POST['req-name'])) { // Building a whitelist array with keys which will send through the form, no others would be accepted later on $whitelist = array('token','req-company','req-email','req-name','req-phone','ext','fax','assign_type','loss_type','req-claim','policy','ded','dol','Clmt-Own','insd','insd_add','insd_city','insd_st','insd-zip','insd-home','insd-work','insd-cell','insd-other','clmt','clmt_add','clmt_city','clmt_st','clmt-zip','clmt-home','clmt-work','clmt-cell','clmt-other','VIN','veh-year','veh-make','veh-model','veh-model','veh-color','lic_pl','location','loc-name','loc-add','loc-city','loc-st','loc-zip','loc-con','loc-phone','desc-loss','desc-dmg','spec-inst','save-company','save-email','save-name','save-phone'); // Building an array with the $_POST-superglobal foreach ($_POST as $key=>$item) { // Check if the value $key (fieldname from $_POST) can be found in the whitelisting array, if not, die with a short message to the hacker if (!in_array($key, $whitelist)) { writeLog('Unknown form fields'); die("Hack-Attempt detected. Please use only the fields in the form"); } } // SAVE INFO AS COOKIE, if user wants name and email saved $saveCompany = $_POST['save-company']; if ($saveCompany == 'on') { setcookie("NA-Company", $_POST['req-company'], time()+60*60*24*365); } $saveName = $_POST['save-name']; if ($saveName == 'on') { setcookie("NA-Name", $_POST['req-name'], time()+60*60*24*365); } $saveEmail = $_POST['save-email']; if ($saveEmail =='on') { setcookie("NA-Email", $_POST['req-email'], time()+60*60*24*365); } $savePhone = $_POST['save-phone']; if ($savePhone =='on') { setcookie("NA-Phone", $_POST['req-phone'], time()+60*60*24*365); } // PREPARE THE BODY OF THE MESSAGE $message = '<html><body>'; $message .= '<img src="http://www.damageana.com/images/DANA_NA_header.png" alt="Assignment Request" />'; $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $message .= "<tr style='background: #eee;'><td><strong>Company:</strong> </td><td>" . strip_tags($_POST['req-company']) . "</td></tr>"; $message .= "<tr><td><strong>Adjuster:</strong> </td><td>" . strip_tags($_POST['req-name']) . "</td></tr>"; $message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['req-email']) . "</td></tr>"; $message .= "<tr><td><strong>Phone:</strong> </td><td>" . strip_tags($_POST['req-phone']) . "</td></tr>"; if($_POST['ext'] !='') {$message .= "<tr><td><strong>Extension:</strong> </td><td>" . strip_tags($_POST['ext']) . "</td></tr>";} if($_POST['fax'] !='') {$message .= "<tr><td><strong>Fax:</strong> </td><td>" . strip_tags($_POST['fax']) . "</td></tr>";} $message .= "<tr><td><strong>Assignment Type:</strong> </td><td>" . strip_tags($_POST['assign_type']) . "</td></tr>"; if($_POST['loss_type'] !='') {$message .= "<tr><td><strong>Type of Loss:</strong> </td><td>" . strip_tags($_POST['loss_type']) . "</td></tr>";} $message .= "<tr><td><strong>Claim #:</strong> </td><td>" . strip_tags($_POST['req-claim']) . "</td></tr>"; if($_POST['policy'] !='') {$message .= "<tr><td><strong>Policy #:</strong> </td><td>" . strip_tags($_POST['policy']) . "</td></tr>";} if($_POST['ded'] !='') {$message .= "<tr><td><strong>Deductible:</strong> </td><td> $" . strip_tags($_POST['ded']) . "</td></tr>";} if($_POST['dol'] !='') {$message .= "<tr><td><strong>Date of Loss:</strong> </td><td>" . strip_tags($_POST['dol']) . "</td></tr>";} if($_POST['insd'] !='') {$message .= "<tr><td><strong>Insured:</strong> </td><td>" . strip_tags($_POST['insd']) . "</td></tr>";} if($_POST['insd_add'] !='') {$message .= "<tr><td><strong>Insured's Address:</strong> </td><td>" . strip_tags($_POST['insd_add']) . "</td></tr>";} if($_POST['insd_city'] !='') {$message .= "<tr><td><strong>Insured's City:</strong> </td><td>" . strip_tags($_POST['insd_city']) . "</td></tr>";} if($_POST['insd_st'] !='') {$message .= "<tr><td><strong>Insured's State:</strong> </td><td>" . strip_tags($_POST['insd_st']) . "</td></tr>";} if($_POST['insd-zip'] !='') {$message .= "<tr><td><strong>Insured's Zip:</strong> </td><td>" . strip_tags($_POST['insd-zip']) . "</td></tr>";} if($_POST['insd-home'] !='') {$message .= "<tr><td><strong>Insured's Home Phone:</strong> </td><td>" . strip_tags($_POST['insd-home']) . "</td></tr>";} if($_POST['insd-work'] !='') {$message .= "<tr><td><strong>Insured's Work Phone:</strong> </td><td>" . strip_tags($_POST['insd-work']) . "</td></tr>";} if($_POST['insd-cell'] !='') {$message .= "<tr><td><strong>Insured's Mobile Phone:</strong> </td><td>" . strip_tags($_POST['insd-cell']) . "</td></tr>";} if($_POST['insd-other'] !='') {$message .= "<tr><td><strong>Insured's Other Phone:</strong> </td><td>" . strip_tags($_POST['insd-other']) . "</td></tr>";} if($_POST['clmt'] !='') {$message .= "<tr><td><strong>Claimant:</strong> </td><td>" . strip_tags($_POST['clmt']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Address:</strong> </td><td>" . strip_tags($_POST['clmt_add']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's City:</strong> </td><td>" . strip_tags($_POST['clmt_city']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's State:</strong> </td><td>" . strip_tags($_POST['clmt_st']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Zip:</strong> </td><td>" . strip_tags($_POST['clmt-zip']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Home Phone:</strong> </td><td>" . strip_tags($_POST['clmt-home']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Work Phone:</strong> </td><td>" . strip_tags($_POST['clmt-work']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Mobile Phone:</strong> </td><td>" . strip_tags($_POST['clmt-cell']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Other Phone:</strong> </td><td>" . strip_tags($_POST['clmt-other']) . "</td></tr>";} if($_POST['VIN'] !='') {$message .= "<tr><td><strong>VIN:</strong> </td><td>" . strip_tags($_POST['VIN']) . "</td></tr>";} if($_POST['veh-year'] !='') {$message .= "<tr><td><strong>Year:</strong> </td><td>" . strip_tags($_POST['veh-year']) . "</td></tr>";} if($_POST['veh-make'] !='') {$message .= "<tr><td><strong>Make:</strong> </td><td>" . strip_tags($_POST['veh-make']) . "</td></tr>";} if($_POST['veh-model'] !='') {$message .= "<tr><td><strong>Model:</strong> </td><td>" . strip_tags($_POST['veh-model']) . "</td></tr>";} if($_POST['veh-color'] !='') {$message .= "<tr><td><strong>Color:</strong> </td><td>" . strip_tags($_POST['veh-color']) . "</td></tr>";} if($_POST['lic_pl'] !='') {$message .= "<tr><td><strong>License Plate:</strong> </td><td>" . strip_tags($_POST['lic_pl']) . "</td></tr>";} $message .= "<tr><td><strong>Unit Location:</strong> </td><td>" . strip_tags($_POST['location']) . "</td></tr>"; if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Name:</strong> </td><td>" . strip_tags($_POST['loc-name']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Address:</strong> </td><td>" . strip_tags($_POST['loc-add']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location City:</strong> </td><td>" . strip_tags($_POST['loc-city']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location State:</strong> </td><td>" . strip_tags($_POST['loc-st']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Zip:</strong> </td><td>" . strip_tags($_POST['loc-zip']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Contact:</strong> </td><td>" . strip_tags($_POST['loc-con']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Phone:</strong> </td><td>" . strip_tags($_POST['loc-phone']) . "</td></tr>";} if($_POST['desc-loss'] !='') {$message .= "<tr><td><strong>Description of Loss:</strong> </td><td>" . htmlentities($_POST['desc-loss']) . "</td></tr>";} if($_POST['desc-dmg'] !='') {$message .= "<tr><td><strong>Description of Damage:</strong> </td><td>" . htmlentities($_POST['desc-dmg']) . "</td></tr>";} if($_POST['spec-inst'] !='') {$message .= "<tr><td><strong>Special Instructions:</strong> </td><td>" . htmlentities($_POST['spec-inst']) . "</td></tr>";} $message .= "</table>"; $message .= "</body></html>"; // MAKE SURE THE "FROM" EMAIL ADDRESS DOESN'T HAVE ANY NASTY STUFF IN IT $pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"; if (preg_match($pattern, trim(strip_tags($_POST['req-email'])))) { $cleanedFrom = trim(strip_tags($_POST['req-email'])); } else { return "The email address you entered was invalid. Please try again!"; } // CHANGE THE BELOW VARIABLES TO YOUR NEEDS $to = 'office@damageana.com'; $subject = 'New Assignment Request'; $headers = "From: " . $cleanedFrom . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; if (mail($to, $subject, $message, $headers)) { echo 'Your message has been sent.'; } else { echo 'There was a problem sending the email.'; } // DON'T BOTHER CONTINUING TO THE HTML... die(); } } else { if (!isset($_SESSION[$form.'_token'])) { } else { echo "Hack-Attempt detected. Got ya!."; writeLog('Formtoken'); } } ?> <!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" xml:lang="fr" lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Assignment Request Form</title> <link rel="stylesheet" href="css/jqtransform.css" type="text/css" media="all" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="all" /> <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript"> google.load("jquery", "1.3.2"); </script> <script type="text/javascript" src="js/jquery.jqtransform.js"></script> <script type="text/javascript" src="js/jquery.validate.js"></script> <script type="text/javascript" src="js/jquery.form.js"></script> <script type="text/javascript" src="js/websitechange.js"></script> </head> <?php // generate a new token for the $_SESSION superglobal and put them in a hidden field $newToken = generateFormToken('form1'); ?> <body> <div id="page-wrap"> <img src="http://www.damageana.com/images/logo.png" alt="DANA_logo" width="750" height="70" /> <h1>New Assignment Request Form</h1> <form action="new_assignment.php" method="post" id="change-form"> <h4>IMPORTANT - PLEASE READ.</h4> <h3> -Please provide us with as much information as possible to aide us in setting up a new appraisal for you. <br> <br> -Please be sure to provide as least one good contact number for the vehicle owner. <br> <br> -Once submitted, you will receive an acknowledgement in your e-mail with information regarding the appraisal for your claim. <br> <br> -If submitted before 3 PM, and no acknowledgement is received by 5 PM, please call our office to confirm we received the request.</h3> <input type="hidden" name="token" value="<?php echo $newToken; ?>"> <div class="rowElem"> <label for="req-company">Company*:</label> <input type="text" id="req-company" name="req-company" class="required" minlength="2" value="<?php echo $_COOKIE["NA-Company"]; ?>" /> </div> <div class="rowElem"> <label for="req-name">Adjuster*:</label> <input type="text" id="req-name" name="req-name" class="required" minlength="2" value="<?php echo $_COOKIE["NA-Name"]; ?>" /> </div> <div class="rowElem"> <label for="req-email">E-mail*:</label> <input type="text" name="req-email" class="required email" value="<?php echo $_COOKIE["NA-Email"]; ?>" /> </div> <div class="rowElem"> <label for="req-phone">Phone*:</label> <input type"text" id="req-phone" name="req-phone" class="required" maxlength="12" value="<?php echo $_COOKIE["NA-Phone"]; ?>" /> </div> <div class="rowElem"> <label for="ext">Extension:</label> <input type="text" id="ext" /> </div> <div class="rowElem"> <label for="fax">Fax:</label> <input type="text" id"fax" /> </div> <h2>Claim Info</h2> <div class="rowElemSelect"> <label for="assign_type">Assignment Type*:</label> <select name="assign_type" class="required"> <option value="Automobile">Automobile</option> <option value="Recreational">Recreational</option> <option value="Heavy Equipment">Heavy Equipment</option> <option value="Property">Minor Property</option> <option value="Estimate Audit">Estimate Audit</option> <option value="Scene Investigation">Scene Investigation</option> <option value="Arbitration">Arbitration</option> <option value="DRP Inspection">DRP Quality Control Inspection</option> <option value="Photos Only">Photos Only</option> </select> </div> <br> <div class"rowElemSelect"> <label for="loss_type">Type of Loss:</label> <select name="loss_type" id="loss_type"> <option value="Collision">Collision</option> <option value="Comprehensive">Comprehensive</option> <option value="Other">Other</option> </select> </div> <div class="rowElem"> <label for="req-claim">Claim #*:</label> <input type="text" id="req-claim" name="req-claim" class="required"> </div> <div class="rowElem"> <label for"policy">Policy #:</label> <input type="text" id="policy" name="policy"> </div> <div class="rowElem"> <label for="ded">Deductible:</label> <input type="text" id="ded" name="ded"> </div> <div class="rowElem"> <label for="dol">Date of Loss:</label> <input type="date" id="dol" name="dol"> </div> <div class="rowElem"> <label for="Clmt-Own">Claimant Vehicle?</label> <input type="checkbox" name="Clmt-Own" id="ClmtCheck" /> </div> <h2>Insured Info</h2> <div class="rowElem"> <label for="insd">Insured:</label> <input type="text" id="insd" name="insd"> </div> <div class ="rowElem"> <label for="insd_add">Address:</label> <input type="text" id="insd_add" name="insd_add"> </div> <div class="rowElem"> <label for="insd_city">City:</label> <input type="text" id="insd_city" name="insd_city"> </div> <br> <div class="rowElem"> <label for="insd_st">State:</label> <select name="insd_st" id="insd_st"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI" selected="selected">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> </div> <div class="rowElem"> <label for="insd-zip">Zip Code:</label> <input type="text" name="insd-zip" id="insd-zip" minlength="5" maxlength="10"> </div> <div class="rowElem"> <label for="insd-home">Home Phone:</label> <input type="text" name="insd-home" id="insd-home" maxlength="12"> </div> <div class="rowElem"> <label for="insd-work">Work Phone:</label> <input type="text" name="insd-work" id="insd-work" maxlength="12"> </div> <div class="rowElem"> <label for="insd-cell">Mobile Phone:</label> <input type="text" name="insd-cell" id="insd-cell" maxlength="12"> </div> <div class="rowElem"> <label for="insd-other">Other Phone:</label> <input type="text" name="insd-other" id="insd-other" maxlength="12"> </div> <br> <div id="Clmt-Info"> <h2>Claimant Info</h2> <div class="rowElem"> <label for="clmt">Claimant:</label> <input type="text" id="clmt" name="clmt"> </div> <div class ="rowElem"> <label for="clmt_add">Address:</label> <input type="text" id="clmt_add" name="clmt_add"> </div> <div class="rowElem"> <label for="clmt_city">City:</label> <input type="text" id="clmt_city" name="clmt_city"> </div> <br> <div class="rowElem"> <label for="clmt_st">State:</label> <select name="clmt_st" id="clmt_st"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI" selected="selected">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> </div> <div class="rowElem"> <label for="clmt-zip">Zip Code:</label> <input type="text" name="clmt-zip" id="clmt-zip" minlength="5" maxlength="10"> </div> <div class="rowElem"> <label for="clmt-home">Home Phone:</label> <input type="text" name="clmt-home" id="clmt-home" maxlength="12"> </div> <div class="rowElem"> <label for="clmt-work">Work Phone:</label> <input type="text" name="clmt-work" id="clmt-work" maxlength="12"> </div> <div class="rowElem"> <label for="clmt-cell">Mobile Phone:</label> <input type="text" name="clmt-cell" id="clmt-cell" maxlength="12"> </div> <div class="rowElem"> <label for="clmt-other">Other Phone:</label> <input type="text" name="clmt-other" id="clmt-other" maxlength="12"> </div> </div> <br> <h2>Damaged Unit Information</h2> <div class="rowElem"> <label for="VIN">VIN:</label> <input type="text" name="VIN" id="VIN" maxlength="17"> </div> <div class="rowElem"> <label for="veh-year">Year:</label> <input type="text" name="veh-year" id="veh-year" maxlength="4"> </div> <div class="rowElem"> <label for="veh-make">Make:</label> <input type="text" name="veh-make" id="veh-make"> </div> <div class="rowElem"> <label for="veh-model">Model:</label> <input type="text" name="veh-model" id="veh-model"> </div> <div class="rowElem"> <label for="lic_pl">License Plate:</label> <input type="text" name="lic_pl" id"lic_pl"> </div> <div class="rowElem"> <label for="veh-color">Color:</label> <input type="text" name="veh-color" id="veh-color"> </div> <div class="rowElem"> <label>Unit Location:</label> <div id="changeLocation"> <input type="radio" name="location" id="owner" value="With the Owner" checked="checked" /> <label for="owner">With the Owner</label> <div class="clear"></div> <label></label> <input type="radio" name="location" id="alt-loc" name="loc" value="At Another Location" /> <label for="alt-loc">At Another Location (i.e. Body Shop, Tow Yard, Workplace)</label> </div> </div> <br> <div class="clear"></div> <br> <br> <div id="loc-info"> <div class="rowElem"> <label for="loc-name">Location Name:</label> <input type="text" name="loc-name" id="loc-name"> </div> <div class="rowElem"> <label for="loc-add">Location Address:</label> <input type="text" name="loc-add" id="loc-add"> </div> <div class="rowElem"> <label for="loc-city">Location City:</label> <input type="text" name="loc-city" id="loc-city"> </div> <div class="rowElem"> <label for="loc-st">State:</label> <select name="loc-st" id="loc-st"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI" selected="selected">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> </div> <div class="rowElem"> <label for="loc-zip">Location Zip:</label> <input type="text" name="loc-zip" id="loc-zip" minlength="5" maxlength="10"> </div> <div class="rowElem"> <label for="loc-con">Location Contact:</label> <input type="text" name="loc-con" id="loc-con"> </div> <div class="rowElem"> <label for="loc-phone">Location Phone:</label> <input type="text" name="loc-phone" id="loc-phone" maxlength="12"> </div> </div> <br> <div class="rowElem"> <label for="desc-loss">Description of Loss:</label> <textarea cols="40" rows="8" name="desc-loss"></textarea> </div> <div class="rowElem"> <label for="desc-dmg">Description of Damage:</label> <textarea cols="40" rows="8" name="desc-dmg"></textarea> </div> <div class="rowElem"> <label for="spec-inst">Special Instructions:</label> <textarea cols="40" rows="8" name="spec-inst"></textarea> </div> <div class="rowElem"> <label> </label> <input type="submit" value="Submit Request" /> </div> <div class="rowElem"> <label> </label> <input type="reset" value="Reset" /> </div> <div id="rowElem"> <label>Click to Save:</label> <input type="checkbox" name="save-company" /> <label for="save-company">Company Name</label> </div> <div class="clear"></div> <div id="rowElem"> <label> </label> <input type="checkbox" name="save-name" /> <label for="save-name">Adjuster's Name</label> </div> <div class="clear"></div> <div id="rowElem"> <label> </label> <input type="checkbox" name="save-email" /> <label for="save-email">Adjuster's E-mail</label> </div> <div class="clear"></div> <div id="rowElem"> <label> </label> <input type="checkbox" name="save-phone" /> <label for="save-phone">Adjuster's Phone</label> </div> </form> </div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-68528-29"); pageTracker._initData(); pageTracker._trackPageview(); </script> </body> </html>
  8. I am trying to create a registration form where users put their name, email and password only. but i want to write an auto generated account number into database table for each user e.g; XY1234567 where XY should not change 1234567 auto generated random number and no duplicates (in numbers only). example... XY1234567 XY2345678 XY2233455 i found code $num_of_ids = 10000; //Number of "ids" to generate. $i = 0; //Loop counter. $n = 0; //"id" number piece. $l = "AAA"; //"id" letter piece. while ($i <= $num_of_ids) { $id = $l . sprintf("%04d", $n); //Create "id". Sprintf pads the number to make it 4 digits. echo $id . "<br>"; //Print out the id. if ($n == 9999) { //Once the number reaches 9999, increase the letter by one and reset number to 0. $n = 0; $l++; } $i++; $n++; //Letters can be incremented the same as numbers. Adding 1 to "AAA" prints out "AAB". } but its not working as i want. Any help please?
  9. Hello all, I am new in php and would like to help me in in code. I would like to implement a html form that will upload to my linux server some files, some info as well and will run a bash command. To be more clear, users will: Send to the linux server two files (I have done it). Select from a drop down list a specific directory, and once this specific directory has been selected to activate one other drop down menu with its childs. Send all those info to a bash script. For case b, assume that we have the following structure my_dir/cars/brand1 my_dir/cars/brand2 my_dir/cars/brand3 my_dir/motors/brand5 my_dir/motors/brand6 the first drop down list should list only cars and motors while the second only brand1, brand2, and brand3 if cars is selected or brand5 and brand6 if motors is selected. For case c, once the form is submitted, I would like the command: ./script.sh –a uploadedfile1 –b uploadedfile2 –c dropdown1 –d dropdpwn2 Any help is appreciated. Best,
  10. Hey guys! I'm trying to add an upload feature to my contact form. I had one before that simply added the image under the text in the email not as an actual attachment and it was pretty easy but I lost the code and can’t seem to find it again. But I seem to be having a problem finding a form that can help me add this. As of now the code in HTML has the upload but the PHP doesn’t at all. If anyone could help me add the rest of the PHP code I'd really appreciate it! HTML: <form name="htmlform" method="post" action="oc.php"><label for="fname"><p>Full Name:</p></label> <input type="text" name="fname" maxlength="50" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td valign="top"> <label for="phone"> <p>Phone Number: </p></label> <input type="text" name="phone" maxlength="50" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td valign="top"> <label for="email"> <p> Email Address: </p></label> <input type="text" name="email" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> </tr> <tr> <td> <h4>DELIVERY INFORMATION:</h4> <label for="address"> <p>Address: </p></label> <input type="text" name="address" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="city"> <p>City: </p></label> <input type="text" name="city" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="state"> <p>State: </p></label> <input type="text" name="state" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="zip"> <p>Zip Code: </p></label> <input type="text" name="zip" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <h4>INFORMATION:</h4> <label for="first"> <p>First Name: </p></label> <input type="text" name="first" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="last"> <p>Last Name: </p></label> <input type="text" name="last" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="rec"> <p>Recommendation ID Number: </p></label> <input type="text" name="rec" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="exp"> <p>Recommendation Experation Date: </p></label> <input type="text" name="exp" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="doc"> <p>Doctors Name: </p></label> <input type="text" name="doc" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="docphone"> <p>Doctors Phone Number: </p></label> <input type="text" name="docphone" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> <label for="ver"> <p>Verification Website: </p></label> <input type="text" name="ver" maxlength="80" size="60" style="color:#000;" required="required"> </td> </tr> <tr> <td> </td> </tr> <tr> <td valign="top"><label for="message"><p>How did you hear about us?</p></label><textarea name="message" id="message" style="background-color:#fff; color:#000;" cols="45"/></textarea></td> </tr> <tr> <td colspan="2" style="text-align:left"> <p> Upload Recommendation:</p> <input type="file" name="pic" id="pic"> <br /> <p> Upload California State ID:</p> <input type="file" name="id" id="id"> <br /> <br /> <input type="image" value="submit"img src="img/sub.png" onmouseover="this.src='img/sub1.png'" onmouseout="this.src='img/sub.png'" /> </form> PHP: <?php // first clean up the input values foreach($_POST as $key => $value) { if(ini_get('magic_quotes_gpc')) $_POST[$key] = stripslashes($_POST[$key]); $_POST[$key] = htmlspecialchars(strip_tags($_POST[$key])); } $ip=$_SERVER['REMOTE_ADDR']; $email_to = "info@example.com"; $email_subject = "Register"; $email_message .= "Full Name: ".$_POST["fname"]."\n"; $email_message .= "Phone Number: ".$_POST["phone"]."\n"; $email_message .= "Email Address: ".$_POST["email"]."\n"; $email_message .= "Address: ".$_POST["address"]."\n"; $email_message .= "City: ".$_POST["city"]."\n"; $email_message .= "State: ".$_POST["state"]."\n"; $email_message .= "Zip Code: ".$_POST["zip"]."\n"; $email_message .= "First Name: ".$_POST["first"]."\n"; $email_message .= "Last Name: ".$_POST["last"]."\n"; $email_message .= "Recommendation ID Number: ".$_POST["rec"]."\n"; $email_message .= "Recommendation Exp Date: ".$_POST["exp"]."\n"; $email_message .= "Doctors Name: ".$_POST["doc"]."\n"; $email_message .= "Doctors Phone Number: ".$_POST["docphone"]."\n"; $email_message .= "Verification Website: ".$_POST["ver"]."\n"; $email_message .= "Message: ".$_POST["message"]."\n"; $userEmail = filter_var( $_POST['email'],FILTER_VALIDATE_EMAIL ); if( ! $userEmail ){ exit; } //email headers $headers = 'From: '.$_POST["email"]."\r\n". 'Reply-To: '.$_POST["email"]."\r\n" . 'X-Mailer: PHP/' . phpversion(); echo (mail($email_to, $email_subject, $email_message, $headers) ? "<html><head><meta http-equiv='Refresh' content='0; url=http://www..com/thankyou.html'><body bgcolor='#fff'> ":"<html><body bgcolor='#fff'><center><font color='white'><h2>We're sorry, something went wrong.</h2></font><p><font color='white'>Please return to <a href='http://www..com'></a>.</font></p></center></body></html>"); $ip=$_SERVER['REMOTE_ADDR']; $email_to = $_POST["email"]; $email_subject = "420 In Action"; $email_message1 = "Welcome! Sincerely, "; //email headers $headers = 'From: '.$_POST["email"]."\r\n". 'Reply-To: '.$_POST["email"]."\r\n" . 'X-Mailer: PHP/' . phpversion(); echo (mail($email_to, $email_subject, $email_message1, $headers) ? "":""); exit(); // test input values for errors $errors = array(); if(strlen($fname) < 2) { if(!$fname) { $errors[] = "You must enter a name."; } else { $errors[] = "Name must be at least 2 characters."; } } if(!$email) { $errors[] = "You must enter an email."; } else if (!validEmail($email)) { $errors[] = "You must enter a valid email."; } if($errors) { // output errors to browser and die with a failure message $errortext = ""; foreach($errors as $error) { $errortext .= "<li>".$error."</li>"; } die("<span class='failure'>The following errors occured:<ul>". $errortext ."</ul></span>"); } // check to see if email is valid function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { $isValid = false; } // local part length exceeded else if ($domainLen < 1 || $domainLen > 255) { $isValid = false; } // domain part length exceeded else if ($local[0] == '.' || $local[$localLen-1] == '.') { $isValid = false; } // local part starts or ends with '.' else if (preg_match('/\\.\\./', $local)) { $isValid = false; } // local part has two consecutive dots else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { $isValid = false; } // character not valid in domain part else if (preg_match('/\\.\\./', $domain)) { $isValid = false; } // domain part has two consecutive dots else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { $isValid = false; } // domain not found in DNS } return $isValid; } ?>
  11. Hi everyone. Pretty desperate, first time that I'm working with php. Learning this language, makes sense, however I can't figure out why my code is not working. Emails are not coming in at all. Additional required info (phone number, first name, last name) should be included in the message. Please help. Thank you everyone. <?php $to = "abcd@abcd.com"; $subject = "From Website Contact Form"; $first = $_REQUEST['first']; $last = $_REQUEST['last']; $email = $_REQUEST['email']; $phone = $_REQUEST['phone']; $MESSAGE_BODY = "Name: " . $_POST["first"] . "\n"; $MESSAGE_BODY = "Name: " . $_POST["last"] . "\n"; $MESSAGE_BODY = "Contact No: " . $_POST["phone"] . "\n"; $MESSAGE_BODY = "Email: " . $_POST["email"] . "\n"; $MESSAGE_BODY = "Requirement: " . nl2br($_POST["message"]) . "\n"; $message = $_REQUEST['message' + 'email' + 'first' + 'last']; $from = $_REQUEST['email']; $headers = "From:" . $from; mail($to, $subject, $MESSAGE_BODY, $headers); echo "Your message has been sent"; ?>
  12. HI recently we have been starting to recieved about 30 spam emails aday. I read that the issue was how my forms were submitting and that it kept bypassing the javascript. I found some code i could use at http://chrisplaneta.com/freebies/php_contact_form_script_with_recaptcha/ but i cannot seem to get the form to function correctly. It is supposed to email me once the form is validated but the email does not seem to be sending. Also i would like the form to redirect to a thank you page once it has been agreed. I did try but it kept telling me the headers had already been called. i am calling the page in with php include. Can you please advise the best way for me to relocate. I have attached a copy of my form.php page which has every thing on. I have also included the code at the bottom of this email Also i would appreciate any comments on what i can include on my form to limit the spammers <?php //If the form is submitted: if(isset($_POST['submitted'])) { //load recaptcha file require_once('captcha/recaptchalib.php'); //enter your recaptcha private key $privatekey = "6Ld5Df4SAAAAAKciqwDco8dfvBR15fGeFVXWcvCO"; //check recaptcha fields $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); //Check to see if the invisible field has been filled in if(trim($_POST['checking']) !== '') { $blindError = true; } else { //Check to make sure that a contact name has been entered $authorName = (filter_var($_POST['formAuthor'], FILTER_SANITIZE_STRING)); if ($authorName == ""){ $authorError = true; $hasError = true; }else{ $formAuthor = $authorName; }; //Check to make sure sure that a valid email address is submitted $authorEmail = (filter_var($_POST['formEmail'], FILTER_SANITIZE_EMAIL)); if (!(filter_var($authorEmail, FILTER_VALIDATE_EMAIL))){ $emailError = true; $hasError = true; } else{ $formEmail = $authorEmail; }; //Check to make sure the subject of the message has been entered $msgSubject = (filter_var($_POST['formSubject'], FILTER_SANITIZE_STRING)); if ($msgSubject == ""){ $subjectError = true; $hasError = true; }else{ $formSubject = $msgSubject; }; //Check to make sure content has been entered $msgContent = (filter_var($_POST['formContent'], FILTER_SANITIZE_STRING)); if ($msgContent == ""){ $commentError = true; $hasError = true; }else{ $formContent = $msgContent; }; // if all the fields have been entered correctly and there are no recaptcha errors build an email message if (($resp->is_valid) && (!isset($hasError))) { $emailTo = 'carlycyber@hotmail.co.uk'; // here you must enter the email address you want the email sent to $subject = 'A new message from: immigration solicitors Manchester' ; $body = "Name :formAuthor \n\nEmail: $formEmail \n\nTelephone :formSubject \n\nContent: $formContent \n\n$formAuthor"; // This is the body of the email $headers = 'From: <'.$formEmail.'>' . "\r\n" . 'Reply-To: ' . $formEmail . "\r\n" . 'Return-Path: ' . $formEmail; // Email headers // Email headers //send email mail($emailTo, $subject, $body, $headers); // set a variable that confirms that an email has been sent $emailSent = true; } // if there are errors in captcha fields set an error variable if (!($resp->is_valid)){ $captchaErrorMsg = true; } } } ?> <?php // if the page the variable "email sent" is set to true show confirmation instead of the form ?> <?php if(isset($emailSent) && $emailSent == true) { ?> <?php $message = "Thank you. Your form has been submitted and a member of our team will contact you shortly.This website is developed for generating immigration enquiries in your area and it is not a law firm, your enquiries will be passed on to a solicitor.We confirm that this website does not belong to a law firm and we have no physical office in your county. Our solicitors are able to provide immigration services all over the UK because they provide a Virtual Service.Responses to your legal enquiries and the legal opinion given to you would be provided by a qualified UK Immigration Solicitor. If you decide to proceed with the solicitor, your matter will be dealt with under a Law firm regulated by the Solicitors Regulatory Authority."; echo "<script type='text/javascript'>alert('$message');</script>"; /*echo "<script language='javascript'> window.location('http://www.immigrationsolicitorsmanchesteruk.co.uk/thankyou.php') </script>";*/ ?> <p>Thank you. Your form has been submitted and a member of our team will contact you shortly.This website is developed for generating immigration enquiries in your area and it is not a law firm, your enquiries will be passed on to a solicitor.We confirm that this website does not belong to a law firm and we have no physical office in your county. </p> <?php } else { ?> <?php // if there are errors in the form show a message ?> <?php if(isset($hasError) || isset($blindError)) { ?> <p><strong>Im sorry. There was an error submitting the form. Please check all the marked fields and try again.</strong></p> <?php } ?> <?php // if there are recaptcha errors show a message ?> <?php if ($captchaErrorMsg){ ?> <p><strong>The recaptcha was not entered correctly. Please try again.</strong></p> <?php } ?> <?php // here, you set what the recaptcha module should look like // possible options: red, white, blackglass and clean // more infor on customisation can be found here: http://code.google.com/intl/pl-PL/apis/recaptcha/docs/customization.html ?> <script type="text/javascript"> var RecaptchaOptions = { theme : 'blackglass' }; </script> <?php // this is where the form starts // action attribute should contain url of the page with this form // more on that you can read here: http://www.w3schools.com/TAGS/att_form_action.asp ?> <form id="contactForm" action="" method="post"> <p> <strong>Full Name</strong><br/> <input class="requiredField <?php if($authorError) { echo 'formError'; } ?>" type="text" name="formAuthor" id="formAuthor" value="<?php if(isset($_POST['formAuthor'])) echo $_POST['formAuthor'];?>"size="25" /></p> <p> <strong>Email </strong><br/> <input class="requiredField <?php if($emailError) { echo 'formError'; } ?>" type="text" name="formEmail" id="formEmail" value="<?php if(isset($_POST['formEmail'])) echo $_POST['formEmail'];?>" size="25" /> </p> <p> <strong>Telephone </strong><br/> <input class="requiredField <?php if($subjectError) { echo 'formError'; } ?>" type="text" name="formSubject" id="formSubject" value="<?php if(isset($_POST['formSubject'])) echo $_POST['formSubject'];?>" size="25" /> </p> <p> <strong>Please give us some information about your enquiry</strong><br/> <textarea class="requiredField <?php if($commentError) { echo 'formError'; } ?>" id="formContent" name="formContent" cols="25" rows="5"><?php if(isset($_POST['formContent'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['formContent']); } else { echo $_POST['formContent']; } } ?></textarea></p> <?php // this field is visible only to robots and screenreaders // if it is filled in it means that a human hasn't submitted this form thus it will be rejected ?> <div id="screenReader"> <label for="checking"> If you want to submit this form, do not enter anything in this field </label> <input type="text" name="checking" id="checking" value="<?php if(isset($_POST['checking'])) echo $_POST['checking'];?>" /> </div> </div> <?php // load recaptcha file require_once('captcha/recaptchalib.php'); // enter your public key $publickey = "6Ld5Df4SAAAAANFKozja9bUlDziJ92c31DDt1j6k"; // display recaptcha test fields echo recaptcha_get_html($publickey); ?> <input type="hidden" name="submitted" id="submitted" value="true" /> <?php // submit button ?> <input type="submit" value="Send Message" tabindex="5" id="submit" name="submit"> </form> <?php } // yay! that's all folks! ?> form issue.txt
  13. Just a bit of background first: I have a contact form set up on one of my domains. It hasn't been updated in 7 years and recently I started getting about 3-8 spam messages daily through it. At some point I updated other sites with code that includes a CAPTCHA. Out of sheer laziness, instead of recoding the contact form that was getting spammed, I just copied & pasted one of the updated forms and changed the necessary details like which e-mail address, URL, etc. Unfortunately, this hasn’t worked out properly. For some reason the CAPTCHA image isn’t being displayed. I keep looking but can't find the error(s). Could someone please take a look at the code and tell me what went wrong? I’d be ever so grateful for any help! The code for the form itself: <form method="post" action="mail-e.php"> <p><input type="text" name="name" id="name" value="who are you?" size="25" /></p> <p><input type="text" name="email" id="email" value="you@whatever.bla" size="25" /></p> <p><input type="text" name="url" id="url" value="http://" size="25" /></p> <p><textarea name="comments" id="comments" rows="1" cols="20">Go on, then. Tell me a story, wingy!</textarea></p> <p><img src="http://echoing.org/captcha.php" alt="humanity check" /><br /> <input type="text" name="captcha" id="captcha" /> <br /> <p><input type="submit" name="submit" id="submit" value="sing to me" /> <input type="reset" name="reset" id="reset" value="out of key" /></p> </form> mail-e.php: <?php session_start(); //Encrypt the posted code field and then compare with the stored key if(md5($_POST['captcha']) != $_SESSION['key']) { die("Error: You must enter the code correctly"); }else{ echo 'You entered the code correctly'; } ?> <?php if (!isset($_POST['submit'])) { include('./header.php'); echo "<h1>HEY!!! You just encountered an error!</h1>\n <p>You don't belong here. <strong>Because it's <em>wrong</em>.</strong> Go back and try again, please.</p>"; include('./footer.php'); exit; } function cleanUp($data) { $data = strip_tags($data); $data = trim(htmlentities($data)); return $data; } $name = cleanUp($_POST['name']); $email = cleanUp($_POST['email']); $url = cleanUp($_POST['url']); $comments = cleanUp($_POST['comments']); if ((empty($name)) || (empty($email)) || (empty($comments))) { include('./header.php'); echo "<h2>Input Error! Looks like you missed some stuff.</h2>\n <p><strong>Name</strong>, <strong>e-mail</strong> and <strong>comments</strong> are required fields. Please fill them in and try again:</p>"; echo "<form action=\"mail-e.php\" method=\"post\"><p>"; echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />"; echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />"; echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />"; echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />"; echo "<img src=\"http://echoing.org/captcha.php\" alt=\"humanity check\" style=\"margin-bottom: 2px;\" /><br />"; echo "<input type=\"text\" name=\"captcha\" id=\"captcha\" /> <br />"; echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />"; echo "</p></form>"; include('./footer.php'); exit; } if (!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",$email)) { include('./header.php'); echo "<h2>Input Error</h2>\n <p>That e-mail address you entered - \"$email\" - is <em>not</em> a valid electronic address. Please edit it and send it in again, please:</p>"; echo "<form action=\"mail-e.php\" method=\"post\"><p>"; echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />"; echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />"; echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />"; echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />"; echo "<img src=\"captcha.php\" alt=\"humanity check\" style=\"margin-bottom: 2px;\" /><br />"; echo "<input type=\"text\" name=\"captcha\" id=\"captcha\" /> <br />"; echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />"; echo "</p></form>"; include('./footer.php'); exit; } $email = preg_replace("([\r\n])", "", $email); $find = "/(content-type|bcc:|cc:)/i"; if (preg_match($find, $name) || preg_match($find, $email) || preg_match($find, $url) || preg_match($find, $comments)) { include('./header.php'); echo "<h1>Error</h1>\n <p>No meta/header injections, please.</p>"; include('./footer.php'); exit; } $recipient = "my email address is here"; $subject = "paint me a wish on a velvet sky"; $message = "Name: $name \n"; $message .= "E-mail: $email \n"; $message .= "URL: $url \n"; $message .= "Comments: $comments"; $headers = "From: a wish painted on the velvet sky \r\n"; $headers .= "Reply-To: $email"; if (mail($recipient,$subject,$message,$headers)) { include('./header.php'); echo "<<p>WOO HOO! Your message was successfully sent to me! I'll read it as soon as I can. I may even respond! Thanks for using the form, fruitcake </p>"; include('./footer.php'); } else { include('./header.php'); echo "<p>Something went awry. Your message didn't go through. Want to take another crack at it? Please do, I'd love to hear from you!</p>"; include('./footer.php'); } ?> captcha.php: <?php //Start the session so we can store what the code actually is. session_start(); //Now lets use md5 to generate a totally random string $md5 = md5(microtime() * mktime()); /* We dont need a 32 character long string so we trim it down to 5 */ $string = substr($md5,0,5); /* Now for the GD stuff, for ease of use lets create the image from a background image. */ $captcha = imagecreatefromjpeg("http://echoing.org/captcha.jpg"); /* Lets set the colours, the colour $line is used to generate lines. Using a blue misty colours. The colour codes are in RGB */ $black = imagecolorallocate($captcha, 0, 0, 0); $line = imagecolorallocate($captcha,233,239,239); /* Now to make it a little bit harder for any bots to break, assuming they can break it so far. Lets add some lines in (static lines) to attempt to make the bots life a little harder */ imageline($captcha,0,0,39,29,$line); imageline($captcha,40,0,64,29,$line); /* Now for the all important writing of the randomly generated string to the image. */ imagestring($captcha, 5, 20, 10, $string, $black); /* Encrypt and store the key inside of a session */ $_SESSION['key'] = md5($string); /* Output the image */ header("Content-type: image/jpeg"); imagejpeg($captcha); ?> I don’t know where it all went wrong as I’m using pretty much the same code without problems here, here and here. The form isn't being used presently (apart from the spam) but I am itching to know what the problem is. P.S. The link to the CAPTCHA image wasn’t always http://echoing.org/captcha.php in the code. On the other forms and initially with this one the code was ./captcha.php but I changed it in case that was the problem. Looks like it isn’t. Thanks in advance!
  14. Hi there, I've built a form that should generate an e-mail, but it's not working properly. At first the page wouldn't display at all due to a problem with the EOD tags, that's fixed and I can now see a page, but when I type something in and hit submit, it's just not doing what it's supposed to do. Like I said it's supposed to e-mail me the data and leave the form filled with the data just submitted; it's doing neither. It is however posting the info into the address bar, so something is happening at least. here's a link to the page: http://www.remembertheprojector.com/php/testform.php here's the code: <?php if ($_POST['parse_var'] == "testform"){ $emailtitle = 'New E-mail'; $youremail = 'junk@remembertheprojector.com'; $namefield = $_POST['name']; $emailfield = $_POST['email']; $messagefield = $_POST['message']; $body = <<<EOD <br><hr><br> Name: $namefield <br /> Email: $emailfield <br /> Message: $messagefield <br /> EOD; $headers = "From: $emailfield\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail("$youremail", "$emailtitle", "$body", "$headers"); $sent = "Thank you!"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Contact Form</title> </head> <body> <table width="400" border="1" cellpadding="0" align="center"> <tr> <td align="center">Contact me? <br /> <br /> <form id="contactform" name="contactform" methord="post" action="testform.php"> <table width="100%" border="0" cellpadding="3"> <tr> <td width="25%" align="right">Name:</td> <td width="75%"> <label for="name"></lable> <input type="text" name="name" id="name" maxlength="30" size="30" value="<?php print "$namefield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Email:</td> <td width="75%"> <label for="email"></lable> <input type="text" name="email" id="email" maxlength="50" size="50" value="<?php print "$emailfield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Message:</td> <td width="75%"> <label for="message"></lable> <textarea name="message" id="message" cols="40" rows="5"><?php print "$messagefield"; ?></textarea> </td> </tr> <tr> <td width="25%"></td> <td width="75%" align="right"> <input type="reset" name="reset" id="reset" value="reset" /> <input type="hidden" name="parse_var" id="parse_var" value="testform" /> <input type="submit" name="submit" id="submit" value="submit" /> </td> </tr> <tr> <td width="100%"><?php print "$sent"; ?></td> </tr> </table> </form> </td> </tr> </table> </body> </html> Also attached is a screen shot of the php so you can see how it's tabbed. Thanks for any help.
  15. Hi I'm trying to set up my first contact form, but I keep getting this error message: Parse error: syntax error, unexpected end of file in /home/remem539/public_html/php/testform.php on line 85 here's my code, what am I doing wrong? <?php if ($_POST['parse_var'] == "testform"){ $emailtitle = 'New E-mail'; $youremail = 'junk@remembertheprojector.com'; $namefield = $_POST['name']; $emailfield = $_POST['email']; $messagefield = $_POST['message']; $body = <<<EOD <br><hr><br> Name: $namefield <br /> Email: $emailfield <br /> Message: $messagefield <br /> EOD; $headers = "From: $emailfield\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail("$youremail", "$emailtitle", "$body", "$headers"); $sent = "Thank you!"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Contact Form</title> </head> <body> <table width="400" border="1" cellpadding="0" align="center"> <tr> <td align="center">Contact me? <br /> <br /> <form id="contactform" name="contactform" methord="post" action="testform.php"> <table width="100%" border="0" cellpadding="3"> <tr> <td width="25%" align="right">Name:</td> <td width="75%"> <label for="name"></lable> <input type="text" name="name" id="name" maxlength="30" size="30" value="<?php print "$namefield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Email:</td> <td width="75%"> <label for="email"></lable> <input type="text" name="email" id="email" maxlength="50" size="50" value="<?php print "$emailfield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Message:</td> <td width="75%"> <label for="message"></lable> <textarea name="message" id="message" cols="40" rows="5"><?php print "$messagefield"; ?></textarea> </td> </tr> <tr> <td width="25%"></td> <td width="75%" align="right"> <input type="reset" name="reset" id="reset" value="reset" /> <input type="hidden" name="parse_var" id="parse_var" value="testform" /> <input type="submit" name="submit" id="submit" value="submit" /> </td> </tr> <tr> <td width="100%"><?php print "$sent"; ?></td> </tr> </table> </form> </td> </tr> </table> </body> </html>
  16. Dear user I write a file upload code in php, the code work's fine but it will upload the file up to 60 KB, when i try to upload more then 60 KB file then the page stuck on loading. The problem is why it is not uploading more then 60kb file? is there any fault in my code please check it out.. My form.php code is... <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="css/bootstrap.css"/> <link rel="stylesheet" href="css/bootstrap.min.css"/> </head> <body> <div class="col-md-6"> <form action="upload.php" method="post" enctype="multipart/form-data"> <label for="">Item</label><br/> <input type="file" name="picture" class="form-control"><br/> <label for="">Description</label><br/> <textarea name="description" id="" placeholder="Enter Item Description" class="form-control" cols="50" rows="20"></textarea><br/> <input type="submit" name="submit" value="Upload" class="btn btn-success"> </form> </div> <script src="js/bootstrap.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/jquery-2.1.1.min.js"></script> <body> </html> my upload.php code is <?php include 'conn.php'; $desc=$_POST['description']; $image=$_FILES['picture']; $image_name=$_FILES['picture']['name']; $placed='uploads/'; if(move_uploaded_file($_FILES['picture']['tmp_name'],$placed.$image_name)) { $smt=$conn->prepare("INSERT INTO images(Image_Name,Description,Placed_On)VALUES('".$image_name."','".$desc."','".$placed."')"); $smt->execute(); header('location:form.php'); } else { echo 'error on uploading file'; } ?>
  17. Hi people, I'm new to PHP, and I'm having some real difficulties with trying to re-populate a radio button selection on a form. Basically, I'm working on a WordPress plugin which uses custom fields to create a Bet custom post type. I need to have my form submit the user input, then re-populate it so that if the user wants to edit and update the Bet data, they don't have to fill in the whole form details again, they can just edit what they need to, and update (re-submit) the form. I've managed to get all of the form elements re-populating, apart from a radio button. I've been trawling round the internet for most of yesterday evening and this morning, trying different things, but nothing I've found works for me. I'd really appreciate some help if anyone knows how to do this. Here's my code so far (non working) <?php $win_status = 'checked = "unchecked"'; $ew_status = 'checked = "unchecked"'; if (isset($bet_details_bet_type)) { $selected_radio = $bet_details_bet_type; if ($selected_radio == 'WIN') { $win_satus = 'checked = "checked"'; } elseif ($selected_radio == 'EW') { $ew_status = 'checked = "checked"'; } } echo '<label for="bet_details_bet_type">Bet Type: </label>'; echo '<input type="radio" name="bet_details_bet_type" id="bet_details_bet_type" value="WIN" '. esc_attr( $win_status) .' /> Win '; echo '<input type="radio" name="bet_details_bet_type" id="bet_details_bet_type" value="EW" '. esc_attr( $ew_status) .' /> Each Way </br>'; $bet_details_bet_type is the VARIABLE that gets sent to / pulled from $_POST I have another function which is handling that, which has the following in it. $bet_details_bet_type = $_POST['bet_details_bet_type']; update_post_meta( $post_id, 'bet_details_bet_type', $bet_details_bet_type ); I know that the sending and retrieving is working okay, as the Value is stored and retrieved when I update (submit) the bet, but I just can't seem to get the radio button to be re-checked to the value that was submitted. Again, if any can help with this I would be very grateful. Thanks, Dweezer
  18. Say there is a complex opt in process where people start to enter their data but certain questions stop them where they close out of the page. They already entered their data and I feel there is a way to grab it and post it to mysql even though they do not click submit. How would this be done? A super simple example (proof of concept) or a link to a tutorial would be very useful.
  19. I am attempting to build a SMTP contact form however when my form is submitted i get an error message from google that says my account has been accessed. Also will this work fine with JS form validation? Thank you in advance. <?php if(isset($_POST['submit'])) { $message= 'Full Name: '.$_POST['fullname'].'<br /> Email: '.$_POST['emailid'].'<br /> Comments: '.$_POST['comments'].' '; require "PHPMailer-master/class.phpmailer.php"; //include phpmailer class // Instantiate Class $mail = new PHPMailer(); // Set up SMTP $mail->IsSMTP(); // Sets up a SMTP connection $mail->SMTPAuth = true; // Connection with the SMTP does require authorization $mail->SMTPSecure = "ssl"; // Connect using a TLS connection $mail->Host = "smtp.gmail.com"; //Gmail SMTP server address $mail->Port = 465; //Gmail SMTP port $mail->Encoding = '7bit'; // Authentication $mail->Username = "me@gmail.com"; //Gmail address $mail->Password = "pass"; // Gmail password // Compose $mail->SetFrom($_POST['emailid'], $_POST['fullname']); $mail->AddReplyTo($_POST['emailid'], $_POST['fullname']); $mail->Subject = "New Contact Form Enquiry"; // Subject $mail->MsgHTML($message); // Send To $mail->AddAddress("me@gmail.com", "Mr. Example"); // Where to send it - Recipient $result = $mail->Send(); // Send! unset($mail); } ?>
  20. I am working on a form with php generated values. What I have right now is as follows: <tr> <td><p>ENTRY TERM: <select name="entry_term" > <option value="">Choose One:</option> <?php $year=date("Y"); for ($y=0;$y<5;$y++) { echo '<option value="Fall '.($year+$y).'">Fall '.($year+$y).'</option>'; echo '<option value="Spring '.($year+$y+1).'">Spring '.($year+$y+1).'</option>'; } ?> </select> </p></td> This currently generates a list of : Fall 2014 Spring 2015 Fall 2015 Spring 2016 Fall 2016 ...etc for next 5 years What I need to do is have this time sensitive to exclude once a specific month has passed. For example once August 2014 has started "Fall 2014" should be excluded... or when Jan 2015 has started "Spring 2015" should be excluded. Can someone help me solve this as I am unsure of how to move forward with this. Thanks,
  21. I'm developing a form which is essentially a simple set of radio buttons. Conceptually, it is like this: Please select a theme from the list: o Black o Blue o Red [submit] [Reset] I'm actually showing a slideshow of images showing the appearance of each of the themes in a slideshow that only shows one image at a time. I want my users to click on the image that represents the theme they want and, ideally, not have to click on the Submit button at all. Then I will save the name of the theme they chose in a cookie (if cookies are enabled). Many years ago, I dabbled in things like CGI and I have a vague recollection, possibly faulty, that it's not difficult to make a form that has only one set of radio buttons treat the selection of one of the radio buttons as a Submit. I don't remember how to do it though. Can anyone advise me on whether it is indeed possible and, if it is, how I make the selection of the radio button cause the form to be submitted?
  22. Hello, I removed .php extension with .htaccess RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php .php is removed, but wherever I have a form where action = somepage.php I am forced to change it to action = somepage these are old websites I am fixing, luckily one has all action =$_SERVER['PHP_SELF'] is there someway to resolve so action takes the posted values no matter if action = somepage.php or action somepage or action = $_SERVER['PHP_SELF'] So Instead of form enctype="multipart/form-data" method="post" action="actionfr.php" I am forced to change it to: form method="post" action="actionfr" Same goes for form method="post" action="<?php echo $_SERVER['PHP_SELF']?>"
  23. I have a multi-step form that offers different options of membership to users with the e-mail domain 'vip.co.uk' I finally have it working but have hit a wall with pulling the variables together to form an URL that can be submitted to the payment gateway in the final step. The variables I need to pass are username, password, email, subscription id (a value attached to a radio button in step 2 - not yet built it). I have a JS fiddle at http://jsfiddle.net/zsasvoo4/15/. The final form will be in PHP and I'd prefer to use that language.
  24. Hello there, I have 2 questions: 1) Look here: http://www.hellastransfers.com/booking/taxi.php I have a form and i want to pass values from URL to fields. So, for example to pass a value to Prefered driver ID field you write this: http://www.hellastransfers.com/booking/taxi.php?drivercode-123 and the value 123 is passed to that field. I did this with this code: <?php $sDriverCode = $_REQUEST['drivercode']; ?> <input style="width:100px;" name="drivercode" id="drivercode" value="<?=$sDriverCode?>" data-mini="true" /> At the same form i have some radio-type fields. Its the one you see at Type of Vehicle (Standard, Premium etc). When i try to do the same, i cannot get this to work. What i am trying to do is this: <?php $sCar = $_REQUEST['vehicle_choice']; ?> <input type="radio" name="vehicle_choice" id="vehicle_standard" value="standard" <?= ($sCar == 'standard' ? 'checked' : '') ?> /> <label for="vehicle_standard" class="myButton">Standard</label> <input type="radio" name="vehicle_choice" id="vehicle_business" value="business" <?= ($sCar == 'business' ? 'checked' : '') ?> /> <label for="vehicle_business" class="myButton">Premium</label> and if write at URL this: http://www.hellastransfers.com/booking/taxi.php?vehicle_choice=business, then i cannot see the Premium radio box as checked. I tested and i confirmed that $sCar gets the value from URL, but somehow it seems that its not controlling the check property of input box. I also tried this: <input type="radio" name="vehicle_choice" id="vehicle_business" value="business" checked="<?= ($sCar == 'business' ? 'checked' : '') ?>" /> this: <input type="radio" name="vehicle_choice" id="vehicle_business" value="business" <? if ($sCar == 'business') { ?> checked <? } ?>" /> and this: <input type="radio" name="vehicle_choice" id="vehicle_business" value="business" <? if ($sCar == 'business') { ?> checked="checked" <? }?> /> with no results. I also tried to avoid short tags (<?= ) and use this <?php echo but still the same. Any ideas? 2) At this link: https://hellastransfers.com/online-booking.html you see the form from this link: http://www.hellastransfers.com/booking/taxi.php If i try to pass values to first link through ULR (https://hellastransfers.com/online-booking.html), values are not passed. What should i do, in order the coding i did at first question to be in valid at this ULR: https://hellastransfers.com/online-booking.html? Thank you in advance
  25. I have a full working order form in PHP. I process it and display it with a process page called "process.php." Whenever this information is displayed on the web page "process.php" I also want it to send me an e-mail with all of the information that it just processed. i.e. Checked checkboxes, text entered, etc. Whenever I try to send the contents of "process.php" to an email $message = include 'process.php'; the process page just goes through an infinite loop displaying itself over and over again instead of sending itself in an email.
×
×
  • 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.