Web Analytics Made Easy -
StatCounter What did I do wrong in this contact script? Help! - CodingForum

Announcement

Collapse
No announcement yet.

What did I do wrong in this contact script? Help!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What did I do wrong in this contact script? Help!

    I am trying to make a contact with basicly: your name, your email, your subject, and your message. I have the form written out, and I tried to do a script to mail it, but it won't work. Could anyone show me what I did wrong?

    Code:
    <td width = "80%" valign = "top">  <br />
    				<table border="0">
    					<form method="post" action="formaction.php">
    					<tr><td>Name:</td><td><input type="text" name="name" value="John Smith"></td></tr>
    					<tr><td>Email:</td><td><input type="text" name="email" value="[email protected]"></td></tr>
    					<tr><td>Subject:</td><td><input type="text" name="subject"></td></tr>
    					<tr><td>Message:</td><td><textarea name="message" rows="10" cols="40"></textarea></td></tr>
    					<tr><td><input type="button" value="Submit"></td><td><input type="reset" value="Reset"></td></tr>
    					</form>
    				</table>
    PHP Code:
    <?php
    if*(isset($_POST['confirm']))*{ 

    ****
    $to*=*'[email protected]';* 
    ****
    $from*=*$_POST['email'];* 
    ****
    $name*=*$_POST['name']; 
    ****
    $subject*=*$_POST['subject'];* 
    ****
    $msg*=*$_POST['message']; 
    ******** 
    ****
    $fin*=*FALSE;
    ****
    $userOutput*=*'';
    **** 
    ****
    $mailer*=*new*SimpleContact
    ****
    $mailReady*=*$mailer->init(*$to,*$from,*$subject,*$msg); 
    ******** 
    *** 
    **** 
    ****
    //ensure*input*is*good 
    ****if(!$mailReady)*{ 
    ********
    $userOutput*=*$mailer->errorMsg
    ****}*else*{ 
    ******** 
    ****
    $to*=*'[email protected]';
    ********
    $from*=*$from;*//*must*be*email*only,*not*"'John*Smith'*<[email protected]>" 
    ********$msg*=*"From:*".$from*."\n".$message;*//*Add*any*extra*message*content*here 
    ********$subject*=*'Site*Feedback:*'.$subject;* 
    ********* 
    ****
    $mailer->sendMail();
    ?>

  • #2
    expand on 'it won't work'. do you get an error? What is SimpleContact? does using it without a form (with hard-coded values) work?
    What's with all the *s? it makes the code difficult to read...
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

    Comment


    • #3
      PHP Code:
      <?php 
      $to 
      "[email protected]";
      $Subject "yourubjectl";
      $message "NAME: {$_POST['fieldname']} {$_POST['surname']}, DOB:{$_POST['DOB']}, Year in school: 
      {$_POST['school_year']}, siblings: {$_POST['siblings']}, bedtime: {$_POST['bedtime']}
      homework time: 
      {$_POST['homework']}, tv time: {$_POST['tv']}, computer time: {$_POST['computer']}
      family time: 
      {$_POST['family']}, time with friends: {$_POST['friends']}";
      mail($to,$Subject,$message);
      if(
      mail){
      echo 
      "<BR />Thanks, message sent";
      }
      else{
      echo 
      "<BR /> An Error occured";
      }
      this is a simple effective contact script
      change the message to and subject also add a like in the email like
      PHP Code:
      $message {$_POST['something']}, from {$_POST['email']}"

      Comment


      • #4
        I do not know where the *s came from, they just showed up when i posted the code. What is that Rafiki? I have no idea what that is. The php code is supposed to send the contents of the form, but when i tested it, it wouldn't work. There was no error, it just woldn't work.

        Comment


        • #5
          sirborder reread Rafiki's post in its entirety. He/she tells you exactly what it is. You'll have to tailor it a bit to get it to fit your needs. Did you write the original script yourself? I'm guessing you didn't. Where did you get it?
          ||||If you are getting paid to do a job, don't ask for help on it!||||

          Comment


          • #6
            btw im a male :P and thanks for telling him that, there are 2-3 people using that script now and it works for them, ofcourse they changed it to suit thier needs,

            Comment


            • #7
              I'm new to php so I don't know exactly how to use that code.

              Comment


              • #8
                Try changing this:

                Code:
                <input type="button" value="Submit">
                to this:
                Code:
                <input type="submit" value="Submit">

                Comment

                Working...
                X