Jump to content

kyalee

Members
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

kyalee's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a table with two columns. One column, the category column, not that it's important, can have multiple entries that are the same. So, assuming that I have ten rows in the table, and the category column has two possible entries, "foo" and "bar", is there a way for me to run a query that will return "foo" and "bar" only once? In other words, is there a search that I can run that will return the two possible categories without giving me every instance where they occur? I hope I'm describing the problem right. I can try again if people don't understand what I'm asking. Thanks. ETA: Oh, nevermind, I found it. In case this ever comes up on someone's search, the answer is SELECT DISTINCT *column* FROM *table*
  2. You mean "<?php" and "?>"? I use them, I just left them out when I pasted the code to save space. I figured you guys didn't care about all of the comment notes in the beginning of the script.
  3. This question isn't so much help me make this work as help me do this better. I updated my contact form to be sticky so that people won't have to reenter their information if they skip a required field or format their email address incorrectly. As of right now, it works fine. But the code makes me itch. It's ugly and it's completely inefficient. //RETREIVING FORMATTING HEADER include('header.inc'); //RETREIVING POST VARIABLES $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $phone = $_POST['phone']; $comments = $_POST['comments']; //STRIP SLASHES $name = stripslashes($name); $company = stripslashes($company); $comments = stripslashes($comments); //"STICKY FORM"; WILL BE DISPLAYED IF THE USER DOES NOT FILL OUT THE FORM CORRECTLY $form = "<form method=\"post\" action=\"contactform.php\"> <fieldset> <legend>* Indicates a required field.</legend> <p><label for=\"name\">*Name:</label> <input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /></p> <p><label for=\"company\">Company:</label> <input type=\"text\" name=\"company\" id=\"company\" value=\"$company\" /></p> <p><label for=\"email\">*Email:</label> <input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /></p> <p><label for=\"phone\">Phone #:</label> <input type=\"text\" name=\"phone\" id=\"phone\" value=\"$phone\" /></p> <p><label for=\"comments\">*Comments:</label> <textarea name=\"comments\" rows=\"10\" cols=\"40\" wrap>$comments</textarea></p> <p class=\"submit\"> <input type=\"submit\" name=\"submit\" type=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" id=\"reset\" value=\"Clear\" /> </p> </fieldset> </form>"; // WHERE THE E-MAIL IS GOING $recipient = 'email@email.com'; //EMAIL SUBJECT $subject = 'Contact Form Submitted'; //WHAT THE EMAIL SAYS $msg = "New Contact Form Submitted with the following information: Name: $name Company: $company Email: $email Phone #: $phone Comments: $comments"; //REQUIRED FIELD ERROR MESSAGE $error_required = "<p>You did not fill in all required fields. Please check the information that you entered below and submit your form again.</p>"; //EMAIL FORMAT ERROR MESSAGE $error_email = "<p>The email address you entered is invalid. Please check the information that you entered below and submit your form again.</p>"; //EMAIL SENT SUCESSFULLY MESSAGE $sucess_msg = "<p>Thank you for your interest. We will contact you with more information as soon as possible.</p>"; //REGULAR EXPRESSION FOR CHECKING CORRECT FORMAT OF EMAIL $emailregexp = "[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})"; //CHECKING THAT INFORMATION HAS BEEN ENTERED IN ALL REQUIRED FIELDS if ((!$name) || (!$email) || (!$comments)) { echo $error_required; echo $form; } //CHECKING THAT EMAIL ADDRESS IS CORRECTLY FORMATTED elseif (!eregi($emailregexp, $email)) { echo $error_email; echo $form; } else { //MAILING FORM mail ($recipient, $subject, $msg, 'From: info@ambercoffee.com'); echo $sucess_msg; } See all those back slashes in the $form variable. Ugly and inefficient. How can I do this better?
  4. I think so too. Although technically it would be my second read project. But it's a pretty big jump from simple contact form to ecommerce. But, yeah, I absolutely wouldn't want anything to do with the money. I have considered using paypal. That would let me be more hands off with the money but still do the design.
  5. Unfortunately, they've tried the ready made ecommerce sites and have yet to find something they like which is why they want something custom. Functionality would probably be very basic. The main requirement is that the site be password protected so that customers need to register an account and log in before being able to see the products. I keep trying to put them off, but them seem to have this idea that I can do anything and since I created their basic website with contact form, clearly I can give them Amazon.com and they don't listen when I tell them that it's so not the same thing.
  6. I'm a relative newbie when it comes to PHP scripting. So far my most complex script has been a contact form for my website. But I'm very skilled in HTML and CSS and do freelance website design. Now I have people pressuring me to create an ecommerce website for them. I'm not looking at a strict time frame, I can take as long as I need to do it, so the really really steep learning curve isn't too much of an issue...probably. I've also made it very clear that I'm not comfortable doing anything that would handle actual credit card transactions. All credit card processing would go through another service. Basically what I would need to do is create a site where people can register an account and place orders, again with all payment going through an outside service. I guess my question is, is it feasible for one person to do that on their own? I don't know what sorts of programming staff they have on hand at most ecommerce websites. I don't mind hard work and I learn best when I have a project at hand to apply the new information too, but if it's totally ridiculous for one person to attempt such a project, I think I'd like to know now. Apologies if this is OT for this forum. I couldn't think of anywhere else to put it. Thanks.
  7. This is a very newbie question, but I can't seem to find an answer that makes sense to me. Often in scripts, especially mail contact forms, I've seen a construction like this: $name = $_POST['name']; $email = $_POST['email']; At the beginning of the script. Two questions: 1. What is the advantage of doing it that way? If in the form itself, you have the input boxes named 'name' and 'email', why do you need to reset them that way? 2. Do you then have to use the construction $_POST['name'] when using the variable throughout the rest of the script or can you continue to use $name the entire way through?
  8. The script can be seen in action here: http://www.astriawebdesign.com/contact.php I'm not at all used to giving out anything that could be used as identifying information on-line, but I guess I'll need to get over that if I'm going to have an on-line based business. *g*
  9. Hi all, I just wrote my very first PHP script ever. It's a simple mail form for use on my webpage along with a contact form. I'd love it if a few of you more experienced people would glance at it and let me know if there are any security vulnerabilities I'm overlooking. Thanks! <?php // PHP SCRIPT TO HANDLE CONTACT FORM include('header.inc'); // WHERE THE E-MAIL IS GOING $recipient = 'me@mysite.com'; //EMAIL SUBJECT $subject = 'Contact Form Submitted'; //WHAT THE EMAIL SAYS $msg = "New Contact Form Submitted with the following information: Name: $name Email: $email Phone #: $phone Comments: $comments"; //REQUIRED FIELD ERROR MESSAGE $error_required = "<p>You did not fill in all required fields. Please return to the contact form and try again.</p>"; //EMAIL FORMAT ERROR MESSAGE $error_email = "<p>The email address you entered is invalid. Please return to the contact form and try again.</p>"; //EMAIL SENT SUCESSFULLY MESSAGE $sucess_msg = "<p>Thank you for your interest. I will contact you with more information as soon as possible.</p>"; //CHECKING FOR REQUIRED FIELDS AND CORRECTLY FORMATED EMAIL if ((!$name) || (!$email) || (!$comments)) {echo $error_required; } elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {echo $error_email; } else { //MAILING FORM mail ($recipient, $subject, $msg, 'From: webmaster@website.com'); echo $sucess_msg; } include('footer.inc'); ?>
×
×
  • 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.