Jump to content

dazzclub

Members
  • Posts

    106
  • Joined

  • Last visited

About dazzclub

  • Birthday 10/29/1982

Contact Methods

  • Website URL
    http://www.flickr.com/people/72537940@N00/

Profile Information

  • Gender
    Male
  • Location
    Hull

dazzclub's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi all, I'm looking for some pointers in regards to my form.. How would I firstly trim the $_POST value of the variables that come through via the form (I'm only using one for now)..I know I'm making a right dogs dinner of it. In my head I'm thinking, trim all the posts first before i even assign a variable to it ( i dont know if thats possible), then use an array for when more values start coming through via the form. You know as i make a contact form that requires more data from the user.. <?php require_once '../connection/dbconfig.php'; include_once('../connection/connectionz.php'); //get the values //Get the request method from the $_SERVER $requestType = $_SERVER['REQUEST_METHOD']; //this is what type //echo $requestType ; if($requestType == 'POST') { //now trim all $_POSTS $search_products = trim($_POST['search_products']); // if(empty($search_products)){ echo '<h4>You must type a word to search!</h4>'; }else{ $make = '<h4>No match found!</h4>'; $new_search_products = "%" . $search_products . "%"; $sql = "SELECT * FROM product WHERE name LIKE ?"; //prepared statement $stmt = mysqli_stmt_init($conDB); //prepare prepared statements if(!mysqli_stmt_prepare($stmt,$sql)) { echo "SQL Statement failed"; }else{ //bind parameters to the placeholder mysqli_stmt_bind_param($stmt, "s", $new_search_products ); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); echo'<h2> Search Result</h2>'; echo 'You searched for <strong><em>'. $search_products.'</em></strong>'; while($row = mysqli_fetch_assoc($result)){ echo '<h4> (ID : '.$row['pid']; echo ') Book Title : '.$row['name']; echo '</h4>'; } } } } ;?> If any one can shed some light on this, or some pointers..that would be very nice... Thanks Darren
  2. I think the problem has been was that the variable i need to echo out the image was only set after i uploaded the file only. So obviously when i refresh the page it's looking at the variable and it's empty, because nothing has been uploaded.. so my first solution, because it's not displaying after refresh, is to query the database to retrieve the most recent INSERT via ID... I think having the ID stops two people retrieving the same image? If not, I'll have to query the database and use their username has a way of identifying their own recent INSERT.. Well, that's my thinking..
  3. Hi mac_guyver, That was a typing error on my behalf...so now this particular code looks like.. echo '<img src="img/tees/'.$image_file.'" />'; Now, it uploads and you can see the image but disappears when i refresh the page....I'm thinking the problem is how i laid out the code and in what order..I'm guessing here..maybe $image_file holds the file name just for the upload only? Thanks
  4. Hi there, I'm trying to get my image to still be visible on a page even after I refresh it. I've managed to insert the file name into the database, store it temporarily and then move it to the right folder.. When i upload (or INSERT INTO a table) it, you can instantly see the image, it just disappears when for example I'll press enter in the browsers url or when i refresh it. Here is my current code $target = "img/tees/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $image_file = basename( $_FILES['uploaded']['name']) ; $ok=1; //remember to sanitize $_POST if($_POST['upload']){ //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ".basename( $_FILES['uploadedfile']['name']). " has been uploaded"; $display_image = '<img src="'.$target.'" title="" alt="" />'; global $dbc; $sql = "INSERT INTO full_range (image) VALUES ('$image_file')"; $result = mysqli_query($dbc, $sql) or trigger_error("SQL", E_USER_ERROR); if($result) { echo 'All done'; } } else { echo "Sorry, there was a problem uploading your file."; } } } And here is the code that displays the image file that's been inserted... echo '<img src="img/tees'.$image_file.'" />'; I've read on the internet that I may need to do pass an img variable to another page such as, display.php?img=name_of_img and the have that in the image src file... <img src="display.php?img=name_of_img" /> but I think I could be getting ahead of myself and making a mountain out of a mole hill.. Any pointers to what I'm doing wrong would be great
  5. Thank you so much, it worked.. Here's the full code if anyone finds it usefull... function search_applications() { global $dbc; echo '<form method="post" action="" id="search">'. "\n"; echo '<label for="search_applications">Search for an application</label>'. "\n"; echo '<input type="text" name="search_applications" />'. "\n"; echo '<input type="submit" name="submit" />'. "\n"; echo '</form>'. "\n"; if(isset($_POST['submit'])){ $search_applications = $_POST['search_applications']; if ($search_applications == "") { echo "<p>You forgot to enter a search term"; } //if (preg_match("/\b$search_applications\b/i")){ if(preg_match("/^[ a-zA-Z]+/", $search_applications)){ //for testing the variables //echo $search_applications; $sql="SELECT title, category, content FROM distributors_content WHERE title LIKE '%" . $search_applications . "%' OR category LIKE '%" . $search_applications ."%' OR content LIKE '%" . $search_applications ."%'"; $result=mysqli_query($dbc, $sql); if(mysqli_num_rows($result) == 0){ echo "There were no matches!"; } //-create while loop and loop through result set while($row=mysqli_fetch_array($result)){ $title =$row['title']; $category=$row['category']; $content=$row['content']; //-display the result of the array echo "<ul>\n"; echo '<li> <a href="index.php?article='.$row['title'].'&&page=application" title=""> '.$title . ' ' . $category . '</a></li>'."\n"; echo "</ul>"; } } } } Thanks again
  6. Hi guys and girls, I am having trouble finding out wether the query made no matches rather than just displaying the matches. So what I would want is for the search term to look at the database, and if there's not matches then say, "No match for your search term" function search_applications() { global $dbc; echo '<form method="post" action="" id="search">'. "\n"; echo '<label for="search_applications">Search for an application</label>'. "\n"; echo '<input type="text" name="search_applications" />'. "\n"; echo '<input type="submit" name="submit" />'. "\n"; echo '</form>'. "\n"; if(isset($_POST['submit'])){ $search_applications = $_POST['search_applications']; if ($search_applications == "") { echo "<p>You forgot to enter a search term"; } //if (preg_match("/\b$search_applications\b/i")){ if(preg_match("/^[ a-zA-Z]+/", $search_applications)){ //for testing the variables //echo $search_applications; $sql="SELECT title, category, content FROM distributors_content WHERE title LIKE '%" . $search_applications . "%' OR category LIKE '%" . $search_applications ."%' OR content LIKE '%" . $search_applications ."%'"; $result=mysqli_query($dbc, $sql); //-create while loop and loop through result set while($row=mysqli_fetch_array($result)){ $title =$row['title']; $category=$row['category']; $content=$row['content']; //-display the result of the array echo "<ul>\n"; echo '<li> <a href="index.php?article='.$row['title'].'&&page=application" title=""> '.$title . ' ' . $category . '</a></li>'."\n"; echo "</ul>"; } }else{ echo "<p>Enter another search term</p>"; } } } Any pointers would be good Thank you
  7. Hello there, Im trying to get my head around sessions and passing the data between pages. So I'm attempting to build a very basic questionnaire. My problem comes when i try to go back to a previous page. I want the user to be able to go back and change their answers if need be. This is the code taken from page one. <?php session_start(); //sends enquiries //page 1 answers $_SESSION['day_1_fridge_indicator'] = $_POST['day_1_fridge_indicator']; $_SESSION['day_2_fridge_indicator'] = $_POST['day_2_fridge_indicator']; $_SESSION['day_3_fridge_indicator'] = $_POST['day_3_fridge_indicator']; ?> and on the second page it looks like this; <?php session_start(); //sends enquiries //page 1 answers $q1 = $_SESSION['day_1_fridge_indicator']; $q2 = $_SESSION['day_2_fridge_indicator']; $q3 = $_SESSION['day_3_fridge_indicator']; ?> If you want a working demo then please visit here >> http://www.lcrhallcrest.com/bmpa-survey/ Thanks for any type of help would be great.
  8. Your right made sense, thank you. Here is the updated code; if(isset($_POST['submitted'])) { $recommend = $_POST['recommend']; //has radio been checked if($recommend == '') { $fail = "<div id=\"fail\"><p>You must select a field before you proceed to the next page</p></div> "; }else{ //$confirm = 'yes '.$contact_us.''; header('Location:page7.php'); } } Thank you Darren
  9. Hi there, I'm working on a questionnaire and I need to ensure that the users cant proceed to the next page without selecting/completing a field. I need to check multiple variables as the path the user takes depends on the submitted questions. So I tried to use if(!isset($response_time_email || $effectivenes ){ but I keep getting stumped. Here is the original code; if(isset($_POST['submitted'])) { $response_time_email = $_POST['response_time_email']; //has radio been checked if(!isset($response_time_email)){ $fail = "<div id=\"fail\"><p>You must select a field before you proceed to the next page</p></div> "; }else{ if(isset($response_time_email)) { //$confirm = 'yes '.$contact_us.''; header('Location:page3.php'); } } } Any help would be great, thank you. Darren
  10. Hi there, I am testing my form so when i press submit i get several variables being displayed as Notice: Undefined index: variable name here I looked at to see if the spelling is right so to rule any further complications these variables now use lower case had include no special characters. These variables are checkboxes on my form.. to see it live visit http://www.lcrhallcrest.com/education.php Here is the actual code function sample_pack() { //$mail=ini_set(SMTP,"smtp.orange.co.uk"); //$mail=ini_set(smtp_port,25); $success =''; $fail = ''; $Error_Name = ''; $ErrorTel = ''; $ErrorEmail = ''; //this will check to see if the form has been completed accordingly if(isset($_POST['submitted'])) { // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $company_name = $contact_name = $tel_number = $email_address = $address = $address_two = $postcode = $city = $conductivitybars = $inks = $lcsheets = $radiationdiscs = $thermometers = FALSE; // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['company_name'])) { $company_name = addslashes ($trimmed['company_name']); } if (preg_match ('/^[A-Z \'.-]{2,60}$/i', $trimmed['contact_name'])) { $contact_name = addslashes ($trimmed['contact_name']); } else { $Error_Name = '<strong class="Error">Please enter a contact name</strong>'; } if ($tel_number= ereg_replace("[^0-9]", "", $trimmed['tel_number'])) { $tel_number = addslashes ($trimmed['tel_number']); } else { $ErrorTel = '<strong class="Error">Please enter your telephone number</strong>'; } // Check for an email address: if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email_address'])) { $email_address = addslashes ( $trimmed['email_address']); } else { $ErrorEmail = '<strong class="Error">Please enter a valid email address</strong>'; } if (preg_match ('/^[A-Z \'.-0|1|2|3|4|5|6|7|8|9]{2,20}$/i', $trimmed['address'])) { $address = addslashes ($trimmed['address']); } else { $address = 'FALSE'; } if (preg_match ('/^[A-Z \'.-0|1|2|3|4|5|6|7|8|9]{2,20}$/i', $trimmed['address_two'])) { $address_two = addslashes ($trimmed['address_two']); } else { $address_two = 'FALSE'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['city'])) { $city = addslashes ($trimmed['city']); } else { $city = 'FALSE'; } if (preg_match ('/^[A-Z \'.-0|1|2|3|4|5|6|7|8|9]{2,20}$/i', $trimmed['postcode'])) { $postcode = addslashes ($trimmed['postcode']); } else { $postcode = 'FALSE'; } //product checkboxes if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['conductivitybars'])) { $conductivitybars = addslashes($trimmed['conductivitybars']); } else { $conductivitybars = 'no'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['inks'])) { $inks = addslashes($trimmed['inks']); } else { $inks= 'no'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['lcsheets'])) { $lcsheets = addslashes($trimmed['lcSheets']); } else { $lcsheets= 'no'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['radiationdiscs'])) { $radiationdiscs = addslashes($trimmed['radiationdiscs']); } else { $radiationdiscs= 'no'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['thermometers'])) { $thermometers = addslashes($trimmed['thermometers']); } else { $thermometers= 'no'; } //addiotional check boxes if ($company_name && $contact_name && $tel_number && $email_address && $address && $address_two && $city && $postcode && $conductivitybars && $inks && $lcsheets && $radiationdiscs && $thermometers ) { // If everything's OK... //insert into database //$q = "INSERT INTO enquiries (first_name, last_name, email, title, company, address_1, address_2, post_code, city, state, country, tel, comments, enquiry_date) VALUES ('$first_name', '$last_name', '$email', '$title', '$company', '$address_1','$address_2', '$post_code','$city', '$state', '$country', '$tel', '$comments', NOW() )"; //$r = mysqli_query ($dbc, $q) or 'insert failed something messed up'; //if (mysqli_affected_rows($dbc) == 1) { { //send mail $headers = "From: LCR Hallcrest \n "; $headers .= " \r\n"; $headers .= "Reply-To: no-replay@lcrhallcrest.com \r\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $body = "Dear <strong>$contact_name</strong> <br /> <br /> We are happy you have spent some time completing our sample pack form. <br /> <br /> Visit <a href=\"http://www.lcrhallcrest.com\" title=\"temperature Sensitive applications\">http://www.lcrhallcrest.com</a> for Temperature Sensitive applications. <br /> <br /> <a href=\"mailto:myemail\" target=\"_blank\" class\"enquiry\">Admin@lcrhallcrest.com</a><br /> <span style=\"font-size:8pt;\">Worlds Largest Producer of Colour Changing Temperature Sensitive - Indicating Graphic Devices and Materials</span> \n\n"; mail($trimmed['email_address'], 'Thank you for visiting LCR Hallcrest', $body, $headers); //finish the page //send enquiry to admin as well //send email aswell $sendTo = "myemail"; $subject = "Thermosmart Sample Pack Request"; $headers = "From:From \n "; $headers .= " $contact_name \r\n"; $headers .= " BCC: myemail \r\n"; $headers .= "Reply-To: no-replay@lcrhallcrest.com\r\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $message ="Hi Linda,<br /> <br /> This email is to inform you that <span style=\"font-weight:bold;\">$contact_name</span> made a sample request.<br /> <br /> <br /> <p>Company: <strong>$company_name</strong></p> <p>Address:<br/> <strong> $address<br /> $address_two<br /> $city<br /> $postcode </strong> </p> <p>tel: <strong>$tel_number</strong></p> <p>email: <strong><a href=\"mailto:$email_address\">$email_address</a></strong></p> <p>Contact name: <strong>$contact_name</strong></p> <p><strong>Requested sample pack</strong>:</p> <p>conductivity bars: <strong>$conductivitybars</strong></p> <p>inks: <strong>$inks</strong></p> <p>lc Sheets: <strong>$lcsheets</strong></p> <p>radiation discs: <strong>$radiationdiscs</strong></p> <p>thermometers: <strong>$thermometers</strong></p> <br /> <br /> From<br /> <a href=\"mailto:myemail\" target=\"_blank\" class\"enquiry\">Admin@lcrhallcrest.com</a><br /> <span style=\"font-size:7pt;\">LCR Hallcrest</span>"; mail($sendTo, $subject, $message, $headers); } $success = "<strong class=\"success\">Thank you <strong>$contact_name</strong> for your enquiry!!</strong>"; // Stop the page. } else { // If it did not run OK. $fail = '<strong id="fail">Can you make sure the required fields have been completed.</strong>'; } } echo ' <form method="post" action="education.php" class="sample_pack"> '.$success.''.$fail.' <fieldset> <legend>Complete form for sample pack</legend> <strong class="required_field">*Required field</strong> <p><label for="company_name">Company Name</label><input type="text" name="company_name" id="company_name" tabindex="1" value=""></p> <p><label for="contact_name" ><span>required</span>'.$Error_Name.'Contact Name</label><input type="text" name="contact_name" id="contact_name" tabindex="2" id="name"></p> <p><label for="tel_number"><span>required</span>'.$ErrorTel.'Tel Number</label><input type="text" name="tel_number" id="tel_number" tabindex="3"></p> <p><label for="email_address"><span>required</span>'.$ErrorEmail.'Email</label><input type="text" name="email_address" id="email_address" tabindex="4"></p> <p><label for="address"><span>required</span>Address</label> <input type="text" name="address" id="address" tabindex="5"></p> <p><label for="address_two"><span>required</span>Address 2</label><input type="text" name="address_two" id="address_two" tabindex="6"></p> <p><label for="city">City</label> <input type="text" name="city" id="city" tabindex="7"></p> <p><label for="postcode"><span>required</span>Postcode</label><input type="text" name="postcode" id="postcode" tabindex="8"></p> </fieldset> <fieldset class="packs"> <legend>Request a sample pack</legend> <ul> <li><input type="checkbox" name="conductivitybars" id="conductivitybars" value="yes" tabindex="9" /><label for="conductivityBars">Conductivity bars</label></li> <li><input type="checkbox" name="inks" id="inks" value="yes" tabindex="10" /><label for="inks">ink</label></li> <li><input type="checkbox" name="lcsheets" id="lcsheets" value="yes" tabindex="11" /><label for="lcsheets">lc sheets</label></li> <li><input type="checkbox" name="radiationdiscs" id="radiationdiscs" value="yes" tabindex="12" /><label for="radiationdiscs">radiation discs</label></li> <li><input type="checkbox" name="thermometers" id="thermometers" value="yes" tabindex="13" /><label for="thermometers">thermometers</label></li> </ul> <p><input type="submit" value="submit" name="submit" tabindex="14"/> <input type="hidden" name="submitted" value="TRUE" /></p> </fieldset> </form>'; } [code] Any help would be great.. Thanks Darren
  11. I've been working on a preg_match for an input that would contain a telephone number.. As the web is international people may put in their characters such as braces, dashes, or plus or even periods....so in essence they could enther a string like this into my tel input field (00+4) 123.123.123 Ive been trying to create a preg_match to expect this, but obviously it doesnt work if (preg_match('/^[0-9][\*( \*)\*.\*+]$/i',$trimmed['tel_number'])) { $tel_number = addslashes ($trimmed['tel_number']); } else { $ErrorTel = '<strong class="Error">Please enter your telephone number</strong>'; } if anyone could point me in the right direction that would be great... Thanks Darren
  12. Hi Dreamwest, Thanks for getting back to me on this... I have just uploaded .htaccess file and i have tested the url http://www.colourchange.com/thermometers/room it displays the correct page but without any of the css styling attached...It should remsemble this page http://www.colourchange.com/thermometers.php?products=thermometers&type=room Should I do anything differently?? With the new url /thermometers/room, would I then replace the old one by editing the actual xhtml file. As the link doesnt seem to change when i use it, it still displays the old one. Thanks for your help on this, i know im asking too much but I'm so lost. Thanks Darren
  13. Hi guys, With the help of a user called thorpe he was able to rerwrite a rule i was after but i wanted to ask a few more questions. As mentioned Thorpe wrote this for me RewriteEngine on RewriteRule ^/thermometers/room$ thermometers.php?products=thermometers He also suggested that a more dynamic rule be used instead. What I would like to do is when the users request thermometers.php?products=thermometers by pressing a link the user would then see thermometers/room/in the browser instead. For this to work would i then need to create the actual folders on my server? i.e thermometers/room/? Can someone point me in the right direction as what would be best please. Thanks for your help. Regards Dazzclub
  14. Hi there, Thanks for your reply and your help. Let me just confirm things, the orginal url is http://www.colourchange.com/thermometers.php?products=thermometers but if possible turn it into http://www.colourchange.com/thermometers.php/products/thermometers or just http://www.colourchange.com/thermometers.php/products/ As it stands, i only have a few urls that need changing like this. Is this possible? Thanks for your help.
  15. Hello all, I have a site im working and it has some urls that i would to give a make over. one url is http://www.colourchange.com/thermometers.php?products=thermometers I would like to turn this into http://www.colourchange.com/thermometers/room/ Here is what i have so far in my .htaccess file RewriteEngine on RewriteRule ^/(.*)/(.*)/thermometers.php?products=thermometers$ http://www.colourchange.com/thermometers/room/ I am currently running this locally, so when i can do it i can then make the neccessary changes to the live site. Thanks, any help or tips would be nice. Dazzclub
×
×
  • 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.