Jump to content

pneudralics

Members
  • Posts

    241
  • Joined

  • Last visited

    Never

Everything posted by pneudralics

  1. Thanks, just took the quotes out and it's working.
  2. lip updates, but not lastlogin. lastlogin is used to record the current datetime. Everytime I hit submit all it gives me are zeros. mysql_query ("UPDATE user SET lip = '$ip', lastlogin = 'NOW()' WHERE id = '$id'");
  3. Yes I do want to be able to compare it later. Later on I want to be able to add uploaded hashed image names to the database. I don't want the same ones to exist.
  4. If the posted string that just got hashed with md5 is already in the database I want to be able to repeat the hashing process until none is found in the database. Then I will allow it to insert into the database.
  5. Let's say for some reason my md5 string is in the database. How can I repeat md5ing strings until one is not found? <?php $string = md5($_POST['string']); if (isset($_POST['submit'])) { $query = "SELECT * FROM table WHERE string = '$string' LIMIT 1"; if ($result = mysql_query($query)) { $row = mysql_num_rows ($result); if ($row = 0) { //insert to database } else { //Repeat md5 string until none is found in database } } } ?>
  6. I want to create a random string. When the random string is created it's inserted into the database. I don't know how to loop the statement if the data is already in the database. if () { //simulating random string created } //Simulating search database for created string if (created random string is in the database) { //start back to simulating random string created and repeat until new string is created } else { //post new string in database }
  7. I eventually want to make a section to edit a slideshow. I can't get it to read the subdirectories under the slideshow directory unless I put editslideshow.php and change the $search_dir = '.' called from connect.php SLIDESHOWPATH = "C:/wamp/www/slideshow/"; /includes/editslideshow.php //Set directory $search_dir = SLIDESHOWPATH; $dp = opendir ($search_dir); echo SLIDESHOWPATH; //List directories while ($item = readdir ($dp) ) { if ( (is_dir ($item)) AND (substr($item, 0, 1) != '.') ) { echo "$item<br />\n"; } } rewinddir ($dp); //Reset pointer
  8. I don't know of any, but when I did something like what you were doing thats how I did it. I would make a database where I can edit the amount of points easily from an admin panel. Then I would just read their points and add my set points to theirs.
  9. You can try reading the gold from the user first then adding 100 to what's read and then update it with the new count. For the refresh you can probably set a timer after they click submit for gold.
  10. Permission when created is 777. I'm not understanding the owner part. This is all on WAMP on my computer.
  11. Something like this: <form> <input type="text" name="input name goes here" value"<?php echo $_POST['input name goes here']; ?>" /> </form Obay beat me to it.
  12. Bam! There you go. Overnight as requested! http://www.phpmotion.com/
  13. I keep getting permission denied error for my rmdir(). All files are deleting but when trying to delete the directory afterwards I keep getting errors. function EmptyDir($search_dir) { $handle=opendir($search_dir); while (($file = readdir($handle))!==false) { @unlink($search_dir.'/'.$file); } closedir($handle); rmdir($search_dir); //Delete directory } EmptyDir($search_dir); //Warning: rmdir(../../gallery/fdfgdfg) [function.rmdir]: Permission denied //Directory:fdfgdfg
  14. I was wondering if it's possible to get the value from a textarea without a user submitting. I have a page that automatically populates the textarea with some stuff. I was wondering if I can some how get the values from the textarea. <textarea name="textarea"> some stuff goes here </textarea> <?php //php goes here to get "some stuff goes here" from textarea ?>
  15. Thanks for the help. Looks like an array. Don't use them that much so I wasn't to familiar with it.
  16. I can't get it to echo everything outside the loop. It only echos 1 data and not all of them if I echo it outside the loop. So I'm thinking maybe if I can save it to a string inside the loop and echo the string outside it might work.
  17. I'm trying to save $imagesubject2 into it's own string outside of the while loop. I want to be able to display all the data from $imagesubject2 outside of the loop. //List files while ($item = readdir ($dp) ) { if ( (is_file ($item)) AND (substr($item, 0, 1) != '.') ) { //Get file size $fs = filesize ($item); //Get file modification date $lm = date ('F j, Y' , filemtime($item)); //Find image $imagepattern = '/^([0-9]){1,}.jpg$/'; $imagesubject = "$item"; if (preg_match($imagepattern, $imagesubject, $imagematches)) { //Open file $imagesubject2 = "$imagesubject"; } } }
  18. I'm trying to write all jpg names that is named with a number to an xml file. Whenever I echo it and look at the source I can see that they are displaying. When I check the test.xml file it only shows one value. How can I make it write more than one value to the xml file? //Set directory $search_dir = '.'; $dp = opendir ($search_dir); //List directories while ($item = readdir ($dp) ) { if ( (is_dir ($item)) AND (substr($item, 0, 1) != '.') ) { echo "$item<br />\n"; } } rewinddir ($dp); //Reset pointer //List files while ($item = readdir ($dp) ) { if ( (is_file ($item)) AND (substr($item, 0, 1) != '.') ) { //Get file size $fs = filesize ($item); //Get file modification date $lm = date ('F j, Y' , filemtime($item)); //Find image $imagepattern = '/^([0-9]){1,}.jpg$/'; $imagesubject = "$item"; if (preg_match($imagepattern, $imagesubject, $imagematches)) { //Open file $imagesubject2 = "<image Thumb=\"tn_$imagesubject\" Large=\"$imagesubject\"/>"; if ($fp = fopen ('test.xml', 'w')) { fwrite ($fp, "$imagesubject2"); fclose ($fp); echo "$imagesubject2"; } } } }
  19. Make it a php page instead of html. You can write html in a php page but not php in a html page.
  20. If you want the errors to display above the contact form just move all the php stuff above the contact form.
  21. Not the best and haven't tested but I'm guessing you want something like the below. Basically if any of the field is left blank then it'll show the div error message with the bullets. If it's not blank then it'll send the email. I'm sure the below can be coded in a different way better. It's a start. <form id="contact-form" method="post" action="/scripts/mailer2.php"> <fieldset> <h2>Your info</h2> <div class="field"> <div class="col col-left"> <label for="name">Your name</label><br> <input name="name" id="name" class="input-text" type="text"> </div> <div class="col col-right"> <label for="company">Company or organization</label><br> <input name="company" id="company" class="input-text" type="text"> </div> </div> <div class="field last-field"> <div class="col col-left"> <label for="email">E-mail</label><br> <input name="email" id="email" class="input-text" type="text"> </div> <div class="col col-right"> <label for="phone">Phone or Skype</label><br> <input name="phone" id="phone" class="input-text" type="text"> </div> </div> </fieldset> <fieldset> <h2>Additional Info / Message</h2> <div class="field"> <label for="message">Please add a short message:</label><br> <textarea name="message" id="message" cols="50" rows="5"></textarea> </div> <div class="field last-field"> <p class="smallnote">Individuals, please include any injuries or preexisting physical conditions. <br><br> Companies, please include number of employees and days requested.</p> </div> </fieldset> <fieldset id="button-fieldset"> <label for="cc" class="label-check"> <input class="input-check" name="cc" id="cc" value="1" checked="checked" type="checkbox"> Receive a copy of this message? </label> <input class="input-hidden" name="submited" value="1" type="hidden"> <input class="input-image" src="img/send-message.gif" alt=" [ send message ] " onmouseover="this.src='img/send-message-hover.gif';" onmouseout="this.src='img/send-message.gif';" onmousedown="this.src='img/send-message-active.gif';" type="image"> </fieldset> </form> <?php //If the form is POSTed, do the following if($_SERVER['REQUEST_METHOD'] == 'POST') { //Get the POSTed data and store in the $ variables $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; //If any field is blank display error if ( empty($name) || empty($company) || empty($email) || empty($phone) || empty($message) ) { echo '<div class="error-message"><p>The message has <em>not been sent</em>. Could you please check the following:</p><ul>'; //If the name field is blank, retun the below error if(!$name) { echo "<li>Your name is missing</li>"; } //If the organization field is blank, retun the below error if(!$company) { echo "<li>Your company/organization name is missing</li>"; } //If the email address field is blank, retun the below error if(!$email) { echo "<li>Your email is missing</li>"; } //If the email address entered appears to be of an incorrect format return the below error elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { echo "<li>You must enter a valid email</li>"; } //If the phone number field is blank, retun the below error if(!$phone) { echo "<li>Please provide phone number or Skype username</li>"; } //If the message field is blank, retun the below error if(!$message) { echo "<li>Please provide us with a short message</li>"; } echo '</ul></div>'; } else { //No blanks $msg = "Full Name: $name\n\nCompany: $company\n\nEmail Address: $email\n\nPhone: $phone\n\nMessage: $message\n\n"; mail("youremail@yourdomain.com", "Website Enquiry", $msg, "From: $name <$email>"); echo '<div class="thankyou-message"><p>Thanks for your message! I will get back to you soon.<br>Namaste</p></div>'; } } ?>
  22. Okay kinda lost...so you want everything on one page? If that' so all you have to do is escape php and start the html. Like this: <?php //If the form is POSTed, do the following if($_SERVER['REQUEST_METHOD'] == 'POST') { //Get the POSTed data and store in the $ variables $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; //If the name field is blank, retun the below error if(!$name) { echo "You must enter a name."; } //If the email address field is blank, retun the below error if(!$email) { echo "You must enter an email address"; } //If the email address entered appears to be of an incorrect format return the below error elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { echo "You must enter a valid email address"; } //If the phone number field is blank, retun the below error if(!$phone) { echo "You must enter a phone number"; } if(!$errors) { $msg = "Full Name: $name\n\nCompany: $company\n\nEmail Address: $email\n\nPhone: $phone\n\nMessage: $message\n\n"; mail("youremail@yourdomain.com", "Website Enquiry", $msg, "From: $name <$email>"); header('Location: http://mysite.com/confirm.html'); } } ?> <form id="contact-form" method="post" action="/scripts/mailer2.php"> <fieldset> <h2>Your info</h2> <div class="field"> <div class="col col-left"> <label for="name">Your name</label><br> <input name="name" id="name" class="input-text" type="text"> </div> <div class="col col-right"> <label for="company">Company or organization</label><br> <input name="company" id="company" class="input-text" type="text"> </div> </div> <div class="field last-field"> <div class="col col-left"> <label for="email">E-mail</label><br> <input name="email" id="email" class="input-text" type="text"> </div> <div class="col col-right"> <label for="phone">Phone or Skype</label><br> <input name="phone" id="phone" class="input-text" type="text"> </div> </div> </fieldset> <fieldset> <h2>Additional Info / Message</h2> <div class="field"> <label for="message">Please add a short message:</label><br> <textarea name="message" id="message" cols="50" rows="5"></textarea> </div> <div class="field last-field"> <p class="smallnote">Individuals, please include any injuries or preexisting physical conditions. <br><br> Companies, please include number of employees and days requested.</p> </div> </fieldset> <fieldset id="button-fieldset"> <label for="cc" class="label-check"> <input class="input-check" name="cc" id="cc" value="1" checked="checked" type="checkbox"> Receive a copy of this message? </label> <input class="input-hidden" name="submited" value="1" type="hidden"> <input class="input-image" src="img/send-message.gif" alt=" [ send message ] " onmouseover="this.src='img/send-message-hover.gif';" onmouseout="this.src='img/send-message.gif';" onmousedown="this.src='img/send-message-active.gif';" type="image"> </fieldset> </form> The errors will appear ontop of your form.
  23. if all you want to do is redirect then follow tendolla's example. if you want your page to look like the rest of the site you can just style your php page. what ill do if this was my page is do some more filtering on the other inputs and not redirect at all. ill just style the page and echo errors or success on the same page.
  24. You can just style the php page instead of having all the redirects. It'll only be one direct depending on the action. Like Tendolla's example.
  25. You can try adding the header into the if ! statements instead of echoing the error. Not sure why you want to do that, but if it's me I'll just leave it how it is.
×
×
  • 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.