PHP - Generate Unixtimestamp Based Off Of Html Form
Hello,
I have ran into a unique scenario. I am trying to generate a unix timestamp (by using the gmmktime function). The problem is, I have multiple tags in a form doing the same thing. for example (I have truncated some of the values for sake of page length/readability): Code: [Select] <label for="dateMonth[6]">Date:</label> Month: <select name="dateMonth[6]" id="dateMonth[6]"> <option value="9">September</option> <option value="10" selected="selected">October</option> <option value="11">November</option> <option value="12">December</option> </select> Day: <select name="dateDay[6]" id="dateDay[6]"> <option value="29">29</option> <option value="30" selected="selected">30</option> <option value="31">31</option> </select> Year: <select name="dateYear[6]" id="dateYear[6]"> <option value="2010" selected="selected">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> </select> Hour: <select name="dateHour[6]" id="dateHour"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> Minute: <select name="dateMinute[6]" id="dateMinute"> <option value="0" selected="selected">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> AM/PM: <select name="AMPM[6]" id="AMPM"> <option value="AM">AM</option> <option value="PM" selected="selected">PM</option> </select> Now, as you can see, I have an array of these elements. AMPM[6] dateHour[6] dateMinute[6], AMPM[7] dateHour[7] dateMinute[7], AMPM[8] and so on... The problem I am having is coming with the logic to consolidate all of the post variables that are 6s to make the unix timestamp, then all of the 7s to make a timestamp, and so on. Could someone please point me in the right direction on how to go about processing this? Thank you! weee Similar Tutorials
I would like to generate team by their seniority based on the available members.
$result = mysqli_query($con, "SELECT * FROM `members` ORDER BY DOJ,DOB"); $perteam =10; $teamstart=1; $teams=15; $required=$perteam*$teams; $data = array(); while( $row = mysqli_fetch_array($result)) { $data[]=$row; } foreach($data as $fetch){ echo $fetch["empname"].'<br>'; }
I used the above code to fetch the members in seniority . Now I want to add another coumns Team and Designation as follows; How to make a form using HTML/PHP with conditional responses based on zip code? What I want to do exactly... zip codes 91900-92600 go to URL www.example.com after submit. All others go to URL www.example.com/page after submit. Any help would be much appreciated. Hi, I'm quite new to PHP so please forgive me if this is a bit simple! I have a form on my website, which uses PHP to generate an email to me, the recipient. It works, but there are two new modifications I need help with. First of all, I want the PHP to generate a 'thank you' email to the person who has submitted the email. Please could somebody show me the code, and where to add it? Secondly, I want the email to come through to me from the email address of the person submitting the form (i.e. replacing the donotreply email address currently). Again, could somebody please show me how to do that? Many thanks in advance Here's the code: <?php // Website Contact Form Generator // http://www.tele-pro.co.uk/scripts/contact_form/ // This script is free to use as long as you // retain the credit link // get posted data into local variables $EmailFrom = "donotreply@simplyskillsgroup.co.uk"; $EmailTo = "robin@trillodigital.co.uk"; $Subject = "Simply Skills Franchise Application"; $name = Trim(stripslashes($_POST['name'])); $surname = Trim(stripslashes($_POST['surname'])); $telephone = Trim(stripslashes($_POST['telephone'])); $email = Trim(stripslashes($_POST['email'])); $dob = Trim(stripslashes($_POST['dob'])); $add1 = Trim(stripslashes($_POST['add1'])); $add2 = Trim(stripslashes($_POST['add2'])); $add3 = Trim(stripslashes($_POST['add3'])); $town = Trim(stripslashes($_POST['town'])); $postcode = Trim(stripslashes($_POST['postcode'])); $where = Trim(stripslashes($_POST['where'])); $employment = Trim(stripslashes($_POST['employment'])); $trade = Trim(stripslashes($_POST['trade'])); $drive = Trim(stripslashes($_POST['drive'])); $crb = Trim(stripslashes($_POST['crb'])); $firstaid = Trim(stripslashes($_POST['firstaid'])); $protect = Trim(stripslashes($_POST['protect'])); $convict = Trim(stripslashes($_POST['convict'])); $coach = Trim(stripslashes($_POST['coach'])); $other = Trim(stripslashes($_POST['other'])); $faca = Trim(stripslashes($_POST['faca'])); $other2 = Trim(stripslashes($_POST['other2'])); $other3 = Trim(stripslashes($_POST['other3'])); $hear = Trim(stripslashes($_POST['hear'])); $confirm = Trim(stripslashes($_POST['confirm'])); // validation $validationOK=true; if (Trim($email)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=http://clientzone.trillodigital.co.uk/simplyskills/error.html\">"; exit; } // prepare email body text $Body = ""; $Body .= "PERSONAL DETAILS"; $Body .= "\n"; $Body .= "\n"; $Body .= "First Name: "; $Body .= $name; $Body .= "\n"; $Body .= "\n"; $Body .= "Surname: "; $Body .= $surname; $Body .= "\n"; $Body .= "\n"; $Body .= "Contact Number: "; $Body .= $telephone; $Body .= "\n"; $Body .= "\n"; $Body .= "Email: "; $Body .= $email; $Body .= "\n"; $Body .= "\n"; $Body .= "Date of Birth: "; $Body .= $dob; $Body .= "\n"; $Body .= "\n"; $Body .= "Address Line 1: "; $Body .= $add1; $Body .= "\n"; $Body .= "\n"; $Body .= "Address Line 2: "; $Body .= $add2; $Body .= "\n"; $Body .= "\n"; $Body .= "Address Line 3: "; $Body .= $add3; $Body .= "\n"; $Body .= "\n"; $Body .= "Town or City: "; $Body .= $town; $Body .= "\n"; $Body .= "\n"; $Body .= "Post Code: "; $Body .= $postcode; $Body .= "\n"; $Body .= "\n"; $Body .= "\n"; $Body .= "FRANCHISE DETAILS"; $Body .= "\n"; $Body .= "\n"; $Body .= "Where in the United Kingdom would you like to operate a Simply Skills franchise: "; $Body .= $where; $Body .= "\n"; $Body .= "\n"; $Body .= "Your current employment or business: "; $Body .= $employment; $Body .= "\n"; $Body .= "\n"; $Body .= "In a position to trade within: "; $Body .= $trade; $Body .= "\n"; $Body .= "\n"; $Body .= "Driving licence: "; $Body .= $drive; $Body .= "\n"; $Body .= "\n"; $Body .= "Enhanced CRB disclosure (within 3 years): "; $Body .= $crb; $Body .= "\n"; $Body .= "\n"; $Body .= "Current first-aid qualification (within 3 years): "; $Body .= $firstaid; $Body .= "\n"; $Body .= "\n"; $Body .= "Child protection training (within 3 years): "; $Body .= $protect; $Body .= "\n"; $Body .= "\n"; $Body .= "Any convictions that would affect your ability to work within schools: "; $Body .= $convict; $Body .= "\n"; $Body .= "\n"; $Body .= "\n"; $Body .= "EXPERIENCE"; $Body .= "\n"; $Body .= "\n"; $Body .= "Highest football coaching qualification: "; $Body .= $coach; $Body .= "\n"; $Body .= "\n"; $Body .= "Other football coaching qualifications: "; $Body .= $other; $Body .= "\n"; $Body .= "\n"; $Body .= "Member of the Football Association Coaches Association: "; $Body .= $faca; $Body .= "\n"; $Body .= "\n"; $Body .= "Other sports/disciplines you are qualified to deliver: "; $Body .= $other2; $Body .= "\n"; $Body .= "\n"; $Body .= "Personal qualities and experience that you feel is beneficial to operating a Simply Skills franchise: "; $Body .= $other3; $Body .= "\n"; $Body .= "\n"; $Body .= "\n"; $Body .= "How did you hear about Simply Skills: "; $Body .= $hear; $Body .= "\n"; $Body .= "\n"; $Body .= "Confirm all information provided is correct: "; $Body .= $confirm; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=http://clientzone.trillodigital.co.uk/simplyskills/thankyou.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=http://clientzone.trillodigital.co.uk/simplyskills/error.html\">"; } ?> I have the content of an email in a database, and I need to generate a screenshot of the email based on that.. I'm thinking this won't be possible in PHP and I'll have to use some service? Anyone know where to begin? Hi I'm trying to count XML elements and generate table row and cell as per result. XML entries generated by users what I'm trying to do is auto generate table rows and cols and paging them bec if XML file get heavier its hard to get results it slow down processing that's why i appreciate paging My XML: Code: [Select] <note> <a1>Keep holding On - Avril Lavigne </a1> <a2>Miley Cyrus - Party In The U.S.A </a2> <a3>Swift Taylor - Breath </a3> <a4>Coldplay - The Hardest Part </a4> <a5>P!nk - Who Knew </a5> <a6>Eminem - Love The Way You Lie ft. Rihanna </a6> <a7>Nelly Furtado - Say It Right </a7> <a8>The Black Eyed Peas - Meet Me Halfway </a8> <a9>Justin Bieber - Baby ft. Ludacris </a9> <a10>N.E.R.D. - Hot-n-Fun (Official Version) ft. Nelly Furtado </a10> </note> Been looking to see if anyone has published something like this. I have a number of projects coming up which entail creating input form pages using PHP. Some of these are quite large as to the number of entries, pages etc.. and the worst part is that I know in advance that they most likely will want to change/add to the form after I am done. So rather than coding them physically in the code, I want to define the form elements in an array that I can store in a database/flat file and when the page loads, read from the array to construct the form output. I don't have any issues with dealing with the database or even using arrays, but I have not been able to come up with an array setup that works. Has anyone done this and would care to share the structure they used. Everything that I find on the net is basically sites that want to host the form, but this will be in a non-Internet accessible site so that is not an option. Hey guys, I'm a total newbie here, and just about as a new to php. My issue: I have a very large .html file that contain multiple articles (I actually have a few of these, but we'll start with one for practicality). The article titles are all wrapped in <h2> tags, there are 10 articles in one file. The articles are very simple, just a title wrapped with <h2> and then a few paragraphs wrapped in <p> tags. What I want to know how to do: I want to know if there's a way to open that file, and have each article saved as it's own .html or .txt document (the title & following paragraphs of each article). Ultimately taking my 1 large file, and creating the subsequent 10 smaller files from the articles inside of it. I am having trouble explaining this in text so I'll try to illustrate: I have "Articles.html" - which contains (article1,article2,article3.. ..article10) I want to split "Articles.html" and create "Article1.html", "Article2.html", "Article3.html", etc. Is that possible? Or am I looking at something far more complex than I can imagine at this point - perhaps something I'd be better off doing by hand? Ultimately I intend to stick all these articles into a database, but that's the 2nd part of what I want to do (and I think will be the easier of the tasks). Let me know if you need any additional information in the event my description above is unclear... I simply am having issues figuring out how to separate out the text into individual articles. Folks, I need to Find and Replace some words in Source HTML, which is saved in a PHP Variable. Example: Quote $html = '<img src="some_source" title="paintball mask Picture" alt="Image for Paintball Mask"> <strong> Best Paintball Mask</strong>'; Find Condition: I want to FInd word "Paintball Mask" in vairiable $html, only where if the word "Paintball Mask" is there in Htaml Tag <Strong> </Strong>. As you can observe in $html, we have "Paintball Mask" in <IMG> Tag also, i want to Skip this because I only Need to COnsider if the word "Paintball Mask" there in <strong></strong> or not. One the words is found in <strong></strong> tag, i need to replace that word, to make it a hyperlink. (I think this bit can be done with strreplace()) But how can i restict my search to only <strong></strong> tag? Let me give Data Again: Quote $html = '<img src="some_source" title="paintball mask Picture" alt="Image for Paintball Mask"> <strong> Best Paintball Mask</strong>'; Find What: Paintball Mask Find in Which Tag: <strong> </strong> Replace it with: <a href="/">Paintball Mask</a> can someone help me with the code? Cheers Natasha Thomas im wanting to change the sql in my query based on if a field is empty or not. if the field is empty then i dont want it to post anything, but if its not empty then it can post the content. heres what i have so far but it does post the content even if the field is empty. (!empty($password)) ? $pass_sql = "u_password = '$password'," : $pass_sql = null; $link->query("UPDATE ".TBL_PREFIX."users SET $pass_sql u_allow_user_pm = '".$_POST['allow_user_pm']."' WHERE u_username = '".$_POST['user_name']."'") or die(print_link_error()); how can i stop it from updating if the field is empty? 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.
Hi there got a bit of a logic question here. I have been looking at doing a remember username and password for a persons login form. You'd need to set this as a cookie right? But when doing so would you place it just as the user has entered the form, or when the user has actually successfully logged in, I know mostly this 1st question would be up to me, but what would you do in your own opinion? On a second note to that, I have been going on this logic, just to try and work it out for myself but it keeps coming out with the encrypted password, is there a much better tutorial than going off my own assumptions? Here's the logic: Code: [Select] <?php session_name('jeremysmith_remember_login'); session_start(); ini_set('display_errors', true); // see whats in the cookies overall! print_r($_COOKIE); // now do logic on the form example: if(!array_key_exists('login', $_POST)) { $message = 'User has not logged in yet, please login below:'; require 'form.php'; } else { if(strlen(trim($_POST['username'])) > 0 && strlen(trim($_POST['password'])) > 0) { // now save them to a cookie maybe? mysql_connect('localhost', '******', '*****') or die (mysql_error()); mysql_select_db('test') or die (mysql_error()); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $sql = sprintf("SELECT * FROM users WHERE username LIKE '$username' AND password LIKE sha1('$password')"); $result = mysql_query($sql) or die (mysql_error()); if($result) { if(mysql_num_rows($result) === 1) { $_SESSION['logged_in'] = true; // this will be our only check for now though! if(IsSet($_POST['remember_login'])) { // but don't remember if they have not logged in, what would be the point in that? setcookie("username", $_POST['username']); setcookie("password", $_POST['password']); header('location: success.php'); } } } else { die(mysql_error()); } } else { $username = trim($_POST['username']); $error = 'You did not enter all the fields required to login, please try again'; require 'auth_form.php'; } } I am just a bit confused, any guidance is massively appreciated, Jeremy. Hi there, I found a Javascript with what I want, but I want it to be in PHP because if people don't have Javascript enabled, they won't see the login. Here is what I have, but I need it to be converted to PHP: Code: [Select] function loginArea() { val = document.loginForm.password.value; switch(val) { case "password1": document.location = 'http://www.google.com/password1-page/'; break; case "password2": document.location = 'http://www.google.com/password2-page/'; break; default: document.location ='http://www.google.com/sorry/'; break; } } Code: [Select] <form name="loginForm" id="loginForm" method="post" action=""> <input name="password" type="text" id="password" maxlength="5" /> <input name="login" type="button" id="login" value="Check" onclick="loginArea()" /> </form> Help? - Steph Hello, is it possible to define the next page after a form submission based on a value from the form ? Example: My form has a dropdown Value 1: Flight Value 2: Flight + Hotel now i'm trying to achieve that if value 1 is chosen after submission it goes to flight.php, if value 2 it should go to flighthotel.php or am i heading into the completely wrong direction here and over complicating things ? Thanks in advance ! I have a form that emails the content to a recipient. Now I want to direct the email to 6 different recipients based on the county they select. I got it to work with just two counties (cases). But my state has over 60 counties and I will be dividing by about 10 counties each. Is there a way to list 10 counties for each case? This is what I have. Code: [Select] switch ($to) { case 'County1': $to = "Joe@mysite.com"; break; case 'County2': $to = "Bob@mysite"; break; default: $to = "default@default.com"; } Hello, i have a form with a dropdown selection with the values 1 to 8, on the submit page i have another form which has 8 divs, now i want to show only a number of those divs based on the selection of the dropdown from the previous page. example: 1st page dropdown value is 4, form gets submitted, on the next page show div 1 & 2 & 3 & 4, and so on. Is this possible? /Edit: i just thought about it again and i think i could use Code: [Select] <?php $dropdown=$_POST['dropdown']; if($dropdown=="1") { ?> around the div tags, but then i would have to make 8 forms and take out 1 div one by one based on the dropdown selection, or is my thinking wrong? Hello there, I'm trying to show a picture based on the value that was chosen in the dropdown menu of the page before the submit. Let's say i'm having a drop down form with 3 values: Porsche, BMW, Audi, the form also consists of a button to submit form and some other text fields but these aren't really relevant. So what i want is, you choose whatever car, let's say BMW, fill in all the other data of the form, hit submit, and on the next page it should show a Picture which i define for each car. I hope i explained that somehow understandable. Thanks in advance, Sabine We recently upgraded from PHP4 to PHP5 and the below script that was working perfectly in 4 has completely stopped working and I can't figure out why for the life of me. I'm not an experienced PHP programmer--I've done some forms, but this is the first time I've used a database. What needs to (and was) happen: A user enters their username in the form and gets a readout of their participation so far that month. The problem(s): I know that it's storing the variable 'user' because it echoes it back properly, but the database is no longer allowing me to select the row based on that variable. I know it's not that I can't connect to the database because if instead of '$user' I change the code to a username I know is in there, I get the proper readout. This all started as soon as I transferred over to PHP5--before that, no problems at all. The database information is all correct, I just took it out for privacy's sake. <form id="feedback" method="post" action="index.php"> <input name="user" type="text" value="Enter user name" size="20" maxlength="50" /><br /> <input name="send" id="send" type="submit" value="Submit" /> </form> <?php if (isset($_POST['user'])) { $_session['user'] = $_POST['user']; } ?> <p>You entered your username as: <strong><? echo $_session['user'];?></strong>. If this is not correct or you do not see your information below, please re-enter your username and click Submit again.</p> <?php $con = mysql_connect("database","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $result = mysql_query("SELECT * FROM March WHERE Username='$user'") or die ('Error: '.mysql_error ()); while($row = mysql_fetch_array($result)) { echo "<table border='0'>"; echo "<tr>"; echo "<td><strong>Username:</strong> </td><td>" . $row['Username'] . "</td></tr>"; echo "<tr><td><strong>Mar. 2 Discussion:</strong></td><td>" . $row['Mar2Q'] . "</td></tr>"; echo "<tr><td><strong>Mar. 2 Poll:</strong></td><td>" . $row['Mar2P'] . "</td></tr>"; echo "<tr><td><strong>Mar. 9 Discussion:</strong></td><td>" . $row['Mar9Q'] . "</td></tr>"; echo "<tr><td><strong>Mar. 9 Poll:</strong></td><td>" . $row['Mar9P'] . "</td></tr>"; echo "<tr><td><strong>Mar. 16 Discussion:</strong></td><td>" . $row['Mar16Q'] . "</td></tr>"; echo "<tr><td><strong>Mar. 16 Poll:</strong></td><td>" . $row['Mar16P'] . "</td></tr>"; echo "<tr><td><strong>March Participation To-Date:</strong></td><td>" . $row['Participation'] . "</td></tr>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> ANY help would be greatly appreciated! I've got a couple hundred people who use this on a regular basis and are starting to ask why it's not working. We have the page that the users enter the information, which shows as this in an html file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Scholarship Form</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link href="style.css" type="text/css" rel="stylesheet" /> </head> <?php ?> <body> <h1 style = "text-align:center">Scholarship Form</h1> <form name = "scholarship" action = "process_Scholarship.php" method = "post"> <p>First Name: <input type="text" name="fName" /></p> <p>Last Name: <input type="text" name="lName" /></p> <p><input type="reset" value="Clear Form" /> <input type="submit" name="Submit" value="Send Form" /> </form> </body> </html> and then the attached file, process_Scholarship.php is the file giving me trouble. We're supposed to be using advanced escaping techniques from our book, and that's when things got tricky. I know it's something silly but I just cant figure it out! Any help asap would be awesome!!!! I'm very new to this and really could use some help. I've got a Web app that has one form that collects data from the user and puts it into a mysql database and has another form that allows the user to select critiera to find records in the database and display them on the page. All this is working just fine, but now that my database is getting more data in it, I want to add functionality to display 10 records on a page with results page navigation links so the user can move forward and backward in the results set. This part is not working and I've put in echo statements to figure out what the code is doing. The problem I'm having is that when the selection critiera pulls more than 10 records from the database, the first page of results is correct per the selection criteria entered by the user on the select form. When the 'next' link is selected to review the second page of results, the query is executed again. But this time the form variables have been reset and the results now contains the entire contents of the db. The start record is set to look at the 11th instance of the results set, so the second page starts with the 11th record in the database instead of the 11th record in the original results set. The original select statement is built by determining which criteria is selected using $_POST against each form variable. How can I retain the form variables or the original select statement so the second execution of the select statement results in the same results set as the first? The other option that may be better is to retain the original results set and avoid re-executing the select statement altogether. But I don't know how to do that either. Any suggestions, code samples or adivice is much appreciated! I have 10 tables in my database. I want load these 10 table names into a drop-down list. If a user selects a value form the drop-down list, a form should be displayed with related to the table. (form fields should be appropriate table's column headers) When user fill the form and submitted, data should be saved in the selected table. Give me a code example to do this. |