Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Everything posted by DeanWhitehouse

  1. Most scripts are custom to the sites and the owners needs.
  2. If you show your whole loop... You can do something like <?php $i = 0; while($rows = mysql_fetch_assoc())//fill it in propers { if($i == 3) { echo "<br>"; $i =0; } echo $rows['stuff']; $i++; } ?>
  3. Or you could use my solution
  4. So you want to get all the records that have the a certain word any where in them like? tester has the word test in it or i am a tester testing this test has the word test in it once? If the latter then you can use the SQL clause LIKE
  5. <?php if (date("U") > date("U", mktime(12,0,0,date("F"),date("d"),date("Y"))) { header("Location: /afternoonschedule"); } else { header("Location: /morningschedule"); } ?>
  6. Without looking at your code i would just say replace the print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; with echo "There is an error"; If you want another way to do this i have just wrote this code for my snippet site <?php //Filename: contact.php //Description: This is a simple contact form to allow people to contact you. //Un-tested function make_safe($un_safe)/*Nice little function i made to run the code through some safety measures*/ { $safe = trim($un_safe);//Removes any whitespace $safe = htmlentities($safe);/*makes any tags into safe versions (special char versions)*/ return $safe; } function check_len($check,$remove)/*used to check the length of a word (can also remove any spaces in the word)*/ { if($remove == true) { $check = str_replace(" ","",$check); } $check = make_safe($check); $check = strlen($check); return $check; } //To learn how to send a basic email from php refer to my previous mail tutorial //http://djw-webdesign.awardspace.com/code.php?snippet=3 //Or the php manual http://uk3.php.net/manual/en/function.mail.php if(isset($_POST['Send_me'])) { //Save everything posted in a variable and make it safe $name = make_safe($_POST['Name']); $email = make_safe($_POST['Email']); $query = make_safe($_POST['Query']); $message = make_safe($_POST['Message']); //Check the length of all the compulsary inputs if(check_len($name,true) == 0) $error[] = "Please enter your name"; if(check_len($query,true) == 0) $error[] = "Please select what the message is regarding"; if(check_len($message,true) == 0) $error[] = "Please enter a message"; //Check for certains chars in an email address if(check_len($email,true) > 0) { $real = array("@","."); if(strpos($email,$real) == 0) $error[] = "Invalid email address"; } //If there is no variable called $error if(!isset($error)) { //Sent From $sender = "Someone somwhere < someone@somesite.com >"; //About $subject = "Site contact - ".$query; //Sent To yourself $recipient = "me< Me@hotmail.com >"; $message = " <html> <body> You have recieved a message from ".$name." from the site.<br> They contacted you regarding ".$query.".<br> They left this email for you to reply to them on.<br><a href=\"mailto:".$email."\">".$email."</a> </body> </html> ";//you will need to escape any double quotation marks.like shown above. $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:'. $sender . "\r\n"; //for more information on headers refer to the php manual mail function. mail($recipient,$subject,$message,$headers);// PHP manual function reference - http://uk3.php.net/manual/en/function.mail.php } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Mail Form</title> </head> <body> <?php if(isset($error)) { echo "There was an error proccessing the request, please correct the below errors<br>"; foreach($error as $er) { echo " ".$er."<br>"; } echo "<br>"; } ?> A star(*) indicates a compulsary input field. <!-- This is a basic form that we will use for inputting the mail, there are html tutorials to explain how to use forms --> <form action="" method="post"> *Name: <input type="text" name="Name" value="" maxlength="20"><br> Email: <input type="text" name="Email" value="" maxlength="20"><br> *Regarding: <select name="Query"> <option selected="selected" disabled="disabled"></option> <option value="general">General</option> <option value="snippet error">Snippet Error</option> <option value="missing page">Missing Page</option> </select> <br> *Message: <br> <textarea rows="5" cols="30" name="Message"></textarea> <br> <br> <input type="submit" name="Send_me" value="Send Mail"> </form> </body> </html>
  7. Hmm, i suppose lucky it hasn't happened to me yet and that i don't modify it before i put it in (much)
  8. Instead of redirecting them if there is an error. Why not just show an error message on the same page? Also i don't think there is any way in PHP or HTML to redirect to another page (in a new tab/window) without the user clicking a link. You could always try javascript
  9. @thorpe, that is just a matter of opinion.
  10. Opening a file is slower and uses more resources than reading a mysql database. I would say you just need to upgrade your hosting package to a dedicated server if the current one can't cope. Although i am not an expert in Servers or response times.
  11. To make it safe to print on screen (if he does later , saves him doing so) and to stop it from affecting the query (although i think mysql_real_escape_string(); might stop that.
  12. <?php function add_zero($num) { if(strlen($num) != 5) { $i = 0; $diff = 5 - strlen($num); while($i < $diff) { $num = 0 .$num; $i++; } return $num; } else { return $num; } } echo add_zero(1); echo "<br>"; echo add_zero(204); echo "<br>"; echo add_zero(12345); ?>
  13. I think you will need to write your own function for this. Gimme me a minute and i will write one.
  14. @thorpe, I said first not instead.
  15. Use htmlentities(); first
  16. What numbers are you using. Show us what the beginning number is and the expected end number. Then we will be able to help better.
  17. meta refresh doesn't have a target attribute, therefore you cannot control where it refreshes the page. It would be better for you to rethink your logic.
  18. http://phpmailer.codeworxtech.com/ http://uk.php.net/manual/en/function.mail.php
  19. Definitely When i learned how to use databases i knew none of that, i still know only a small amount of it. When you have learned that, you will be able to plan and create databases that make your work a lot easier. Edit: Also eddie i would advise looking at code snippets and working out how they work and in effect learning new functions etc. It just so happens i have a code snippet site http://djw-webdesign.awardspace.com/snippet.php?cat=1 That is the php section. I would also say you should visit sites such as tizag.com and w3schools.com
  20. Tried it and excelwriter couldn't get either to work properly (needed some other files i couldn't find), and neither allow editing. Only read and write, nevermind will convince them to use mysql.
  21. There is no pre-built function for it, you need to learn how to use image GD functions. You could always use CSS/HTML to just visibly merge the images on the page.
  22. Yes, look at image gd functions
  23. And the problem with that is? It doesn't matter if you have a gap in the numbers as they are just used as unique identifiers.
  24. To create php files you would just use fwrite
×
×
  • 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.