Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. Wow..3 great ways to get 'er done! Thanks! I'm snagging all these as 'snippets' in my code library.
  2. skali, that's good to know. I'll save that as a snippet and use it as it looks quite compact.
  3. Thanks to each and every one of you for the responses! I like the idea of the DATEDIFF function simply because I didn't insert the dates as timestamps and i'd have to convert them to timestamps then back again, etc. if I did it another way. I'll plug in that code and read up on the DATEDIFF function.
  4. I have people posting ads and when the ad is posted I have two fields populated at that time: date_created date_expired With the date expired being 7 days after the date created. Both are in this format: 03/12/07 What I am doing is preventing someone from posting more than one ad per 7 days. I'm validating against their email address for that. But I want to display the date that they would be eligible as well as determine if they are eligible to post or not which would require comparing today's date with probably using the now() function against the date_expired in the database. If the today's date is past then no problem. If not, then it would display an error. Here's what I have on this right now: <?php // duplicate email check function emailCheck() { $email = $_POST['email']; $sql = "SELECT * FROM users WHERE email='$email'"; $results = mysql_query($sql) or die(mysql_error()); $newad_date = $results['date_created']; $num_rows = mysql_query($results); if ($num_rows >= 0){ echo "<h3>Duplicate Ad Error</h3><p>You are allowed one ad per every 7 days. You will be eligible to sumit a new ad on $newad_date."; } } ?>
  5. Use the 'header' function: This would go in your 'if' statement that is validating if the login was correct.
  6. Are you getting an error? If so, please post. I think, if you are, it's because you have a right parentheses instead of a curly bracket to close your if statement. Yours: Correct:
  7. If i'm understanding, you want the page to be split for displaying the results? Like in a frameset? Or, you could have the output written to two different tables. One at the top of the page and one below it.
  8. Why is it loading with the page instead of executing when they hit the submit button? From it's appearance, you're validating a user's login identity.
  9. Question. Do you have access to this database in any other way? Like through a control panel or PHP MyAdmin? I'm beginning to wonder if it even exists.
  10. Just for the heck of it, try this for the connection part: mysql_connect ($host, $user, $pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($db);
  11. Also, in a 'switch' statement can I use functions in the case parameters? Example, please?
  12. Snooble, thanks for your post and suggestions. Initially that's the way I had it set up...multiple tables. One table for each 'type' of ad. That means, though, that I need to create 6 separate form parsing scripts. Although they are similar they have the slightest differences. Once I get the 'master' form done then the others could be derived from it. Ok, so in the ad registration, basically the way it would work is kind of like adding your site to Yahoo or DMOZ where first you have to navigate to the sub-category and then the Post Your Ad link will be there. I can snag what sub-cat it is via the $_GET in the URL. With your suggestion, then, you'd say using a switch statement at that point would then determine what form shows. Is that what you meant?
  13. That is really weird. If you want to, try Orio's code suggestion instead. It's similar but uses some additional techniques that could be really helpful like the strtolower function that changes everything to lowercase which, in turn, makes it easier to validate.
  14. I'm creating a classified ads system for a client. There will basically be 6 types of ads: Services Housing Jobs Personals Gigs For Sale Each has it's own set of questions in the registration form but there are also some common questions. For example, all have these: Title Location Price Description Email Email Use (3 choices on how the people would respond) The 'Housing' ads have price but the 'Jobs' ads use compensation as the title. Some ads allow images like housing, personals, and for sale. But jobs, services and gigs do not. The question I have is about structure. Should I have one table called 'ads' that holds all these fields and deal with the insert queries accordingly. Or, should I have separate tables for each kind of ad so that the queries are specific to that table? There would need to be a few 'connected' fields as well that would be present in all the tables. They would be: ad_id cat_id subcat_id confirmation_status (I will be requiring that they 'activate' the ad by responding to a link. Default is 0 while activated would be 1) date_created date_expired I'm looking for some guidance about the most efficient way to construct this from anyone who has had experience with this type of thing. Thanks in advance!
  15. http://www.phpfreaks.com/forums/index.php/topic,37442.0.html
  16. Ok, so let's see if i'm clear on this. Not only are you getting the field names from the database but you are also allowing the user to create new ones named whatever they want and however many they want... is that right? Then you want to build a form based upon what they've created in the database... is that right for step 2? Then i'm also going to have to assume that you have a separate table for each person. Otherwise, exponentially, you could have someone looking at 1,000+ fields if they showed up late for the party. In other words, if i'm the 20th guy to come to the site and the previous 19 have each added a few fields and your code loops through that same table to display the form for me then it could contain things like "do you have pink bunny slippers". Not sure how this is structured in your database.
  17. You're declaring a 'case' which is part of a 'switch' function but no 'switch' is declared. case "new":
  18. Ok, that's easy enough. <?php // first snag the field data from POST $name = $_POST['name']; $address = $_POST['address']; $email = $_POST['email']; // match those to your field names and one for each field // mysql stuff $sql = "INSERT INTO tablename (field1, field2, field3, etc.) VALUES '$name', '$address', '$email' "; $results = mysql_query($sql) or die(mysql_error()); if(!$results) { echo "Insert did not work. Try again"; } else { echo "Records inserted successfully!"; } ?>
  19. Here's an example: <?php // input error checking if ($username=="") { $err.= "Please provide a username<br/>"; } if (!$email) { $err.= "Please provide your email address<br>"; } if ($email) { if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $err.= $email. " is not a valid email address.<br/>"; } } if ($password=="") { $err.= "Please provide password<br/>"; } if ($confirmPass=="") { $err.= "Please confirm your password.<br/>"; } if ($confirmPass != $password) { $err.= "Your passwords do not match. Please re-enter your passwords."; } if (!$secure) { $err.= "No security code entered<br/>"; } if (($secure!=$match) && ($secure!="")) { $err.= "Security code mismatch<br/>"; } if ($err=="") { If no errors then all the code between these brackets would execute } ?>
  20. Ok, so I have this right, you want to create the form using PHP and also populate the text boxes with what is entered into the fields of your database?
  21. Do you have the $errorstring defined in this function? DisplayAddForm($errorstring);
  22. We need to know what line 60 contains. You should probably post the whole script so we can help.
×
×
  • 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.