Jump to content

Beeeeney

Members
  • Posts

    193
  • Joined

  • Last visited

Everything posted by Beeeeney

  1. Hi all, I'm developing something for work and I've hit a bit of a problem. Basically, I have a form that submits info to a database. On the form I have generated dropdowns for selecting a date. <select name="day"> <option selected>Select</option> <?php $day=1; while($day<32) { ?> <option value="<?php echo $day; ?>"><?php echo $day; ?></option> <?php $day++; } ?> </select> <select name="month"> <option selected>Select</option> <?php $month = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "Novermber", "December"); foreach ($month as $key) { ?> <option value="<?php echo $key; ?>"><?php echo $key; ?></option> <?php } ?> </select> <select name="year"> <option selected>Select</option> <?php $year=1901; while($year<2012 && $year > 1900) { ?> <option value="<?php echo $year; ?>"><?php echo $year; ?></option> <?php $year++; } ?> </select> But when I try to submit this to the database, it gets sent as either: Select/Select/Select ^ That's when trying to submit it as three variables like: $day/$month/$year Or when I try to submit it as an array $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; $datex = array($day, $month, $year); It gets submitted as just "Array" in the database. Here's my full code for the DB entries: <?php $title = $_POST['Title']; $firstname = $_POST['Firstname']; $middlename = $_POST['Middlename']; $lastname = $_POST['Lastname']; //$DOB = $passportno = $_POST['PassportNo']; //$DOE = //$DOI = $nationality = $_POST['Nationality']; $issuecountry = $_POST['Issuecountry']; $fullname = $_POST['Fullname']; $address = $_POST['Address']; $postcode = $_POST['Postcode']; $relationship = $_POST['Relationship']; $mobilenumber = $_POST['Mobilenumber']; $daytimephone = $_POST['Daytimephone']; $eveningphone = $_POST['Eveningphone']; $email = $_POST['Email']; $insuranceco = $_POST['Company']; $policyno = $_POST['Policynumber']; $underwriter = $_POST['Underwriter']; $emergencyphone = $_POST['Emergencynumber']; $bookingref = $_POST['Bookingreference']; $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; $datex = array($day, $month, $year); require("dbconnection.php"); $query = "INSERT INTO `customerinfo` (`ID`, `title`, `firstname`, `middlename`, `lastname`, `dob`, `passportno`, `doi`, `doe`, `nationality`, `issuecountry`, `fullname`, `address`, `postcode`, `relationship`, `mobile`, `daytime`, `evening`, `email`, `insuranceco`, `policyno`, `medicalcompname`, `medicalcontact`, `bookingref`) VALUES ('NULL', '$title', '$firstname', '$middlename', '$lastname', '$datex', '$passportno', 'Date', 'Date', '$nationality', '$issuecountry', '$fullname', '$address', '$postcode', '$relationship', '$mobilenumber', '$daytimephone', '$eveningphone', '$email', '$insuranceco', '$policyno', '$underwriter', '$emergencyphone', '$bookingref')"; mysql_query($query) || die("Connection failed for some reason."); if ($query) { echo "Database successfully updated!<br><br>Click <a href=\"http://www.planetcruise.co.uk\">here</a> to return to the home page."; } else { echo "Naw."; } ?> Anyone know how I can get it to just submit an actual date?
  2. You just save the information about the products they selected in a variable an array, then echo it back on the confirmation page.
  3. Does your URL change in your browser once you send the information to the database? There's probably a command in the URL making it update when you refresh. That doesn't sound like it makes sense, reading it back. I'll show an example: When you update, does your site change from "www.website.com/index.php" to something like "www.website.com/index.php?updatedb=true" or something similar? Basically, does your URL change? If it does then you're refreshing that second URL and asking it to update the database.
  4. That says "If there is something in the $warnings variable.." then you would tell it to do something.
  5. This is one of those situations where I want to reach out through someone's computer screen and slap some sense into them.
  6. Just echo the table back to the browser. Let them read it and confirm, then submit it to a 'confirmed orders' table.
  7. You need a table in your database that stores everything they enter into the form, which you can then echo back to the browser for them to confirm. If they confirm, have it submit to another table where the confirmed orders are kept. That way you can keep track of who's ordering and going through with it and who's cancelling at the last minute.
  8. I started learning with a video tutorial by some guy named Kevin Skoglund. He explains it in the plainest of English.
  9. I consider myself an amateur at best. Still way too much to learn and not enough time to learn it. From PHP.net: // Prints something like: Monday 8th of August 2005 03:12:46 PM echo date('l jS \of F Y h:i:s A'); Just play with it a little bit.
  10. I wasn't trying to discourage you at all. I was merely stating that there isn't really another way your code could be written. You can have more than one parameter inside the date(); function. http://php.net/manual/en/function.date.php
  11. So why don't you create some sort of validation that doesn't let it break when a file name starts with a space?
  12. Why don't you take 15px off the max-width?
  13. It's the most basic PHP code possible. I can only think of one task that would be more basic and that would be to echo "Hello, world!" into the browser. I just meant change your elseif statement to today's date and see if it echos "Christmas day is tomorrow". Also, remove the $hour variable, you don't need it.
  14. Change the date on the script to today?
  15. upfile('foto1',$_SESSION['userid']) function upfile($file,$path){ $allowedExts = array("jpg", "jpeg", "gif", "png"); $extension = end(explode(".", $_FILES[$file]["name"])); if ((($_FILES[$file]["type"] == "image/gif") || ($_FILES[$file]["type"] == "image/jpeg") || ($_FILES[$file]["type"] == "image/png") || ($_FILES[$file]["type"] == "image/pjpeg")) && ($_FILES[$file]["size"] < 2000000) && in_array($extension, $allowedExts)) { if ($_FILES[$file]["error"] > 0) { echo "Return Code: " . $_FILES[$file]["error"] . "<br />"; } else { echo "Upload: " . $_FILES[$file]["name"] . "<br />"; echo "Type: " . $_FILES[$file]["type"] . "<br />"; echo "Size: " . ($_FILES[$file]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES[$file]["tmp_name"] . "<br />"; if (file_exists("usrpics/".$path .'/'. $_FILES[$file]["name"])) { echo $_FILES[$file]["name"] . " already exists. "; } else { move_uploaded_file($_FILES[$file]["tmp_name"], "usrpics/".$path.'/'. $_FILES[$file]["name"]); echo "Stored in: " . "usrpics/" .$path. $_FILES[$file]["name"]; } } } else { echo "Invalid file"; } $_SESSION['path'] ='usrpics/'.$path.'/'.$_FILES["name"] ; return TRUE ; } upload('foto1',$_SESSION['userid']) function upload($file_id,$folder) { $types="jpg,png,gif,jpeg"; $folder = 'usrpics/'.$folder ; if(!$_FILES[$file_id]['name']) return array('','No file specified'); $file_title = $_FILES[$file_id]['name']; //Get file extension $ext_arr = split("\.",basename($file_title)); $ext = strtolower($ext_arr[count($ext_arr)-1]); //Get the last extension //Not really uniqe - but for all practical reasons, it is $uniqer = substr(md5(uniqid(rand(),1)),0,5); $file_name = $uniqer . '_' . $file_title;//Get Unique Name $all_types = explode(",",strtolower($types)); if($types) { if(in_array($ext,$all_types)); else { $result = "'".$_FILES[$file_id]['name']."' is not a valid file."; //Show error if any. return array('',$result); } } //Where the file must be uploaded to if($folder) $folder .= '/';//Add a '/' at the end of the folder $uploadfile = $folder . $file_name; $result = ''; //Move the file from the stored location to the new location if (!move_uploaded_file($_FILES[$file_id]['tmp_name'], $uploadfile)) { $result = "Cannot upload the file '".$_FILES[$file_id]['name']."'"; //Show error if any. if(!file_exists($folder)) { $result .= " : Folder don't exist."; } elseif(!is_writable($folder)) { $result .= " : Folder not writable."; } elseif(!is_writable($uploadfile)) { $result .= " : File not writable."; } $file_name = ''; } else { if(!$_FILES[$file_id]['size']) { //Check if the file is made @unlink($uploadfile);//Delete the Empty file $file_name = ''; $result = "Empty file found - please use a valid file."; //Show the error message } else { chmod($uploadfile,0777);//Make it universally writable. } } return array($file_name,$result); } Just helping you get more replies.
  16. I can't answer your question but kudos for the username.
  17. <script> if (BrowserDetect.browser == 'Firefox' ) { //Load your stylesheet } </script>
×
×
  • 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.