+ Post New Thread
Results 1 to 10 of 10
Web Development Thread, Auto Submitting a Form in Coding and Web Development; Hiya, I am trying to make the a form to go onto our website, so that parents can email in ...
  1. #1

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,821
    Thank Post
    272
    Thanked 1,140 Times in 1,036 Posts
    Rep Power
    350

    Auto Submitting a Form

    Hiya,

    I am trying to make the a form to go onto our website, so that parents can email in a change of data e.g email address. I don't think it should be done on the web personally but thats not up to me.

    my question is how can i make this form auto submit without it having to open in outlook etc

    the main parts of the page are here

    HTML Code:
    <script language ="JavaScript">
    function SubmitForm() 
    {
    document.form1.action = "mailto:emailaddress@domain";
    document.form1.submit() 
    }
    function ResetForm() 
    {
    document.form1.reset()
    }
    </script>
    </head>
    
    <body>
    <form name="form1" action="">
      <p>Students Name  
        <input type="text" name="Students Name" />
      </p>
      <p>Your Name: <input type="text" name="parentsname" /> </p>
      <p>Contact Email: <input type="text" name="Contact Email" />&nbsp;</p>
      <p>DOB of Student: <input type="text" name="DOBStudent" /></p>
      <p>
      Details to be Updated:</p>
      <p>
        <input type="radio" name="dataforchange" value="Email address" />
        Email Address</p>
      <p>
        <input type="radio" name="dataforchange" value="home address" />
        Home Address  </p>
      <p>
        <input type="radio" name="dataforchange" value=" make wicki work" />
      I am only doing this so that you have to work lots!</p>
      <p>Please give further details here:</p>
      <p> 
        <textarea name="furtherinfo" cols="100" rows="5">Please Provide Further Information Here</textarea>
      ;</p>
      <p> <a href="javascript: SubmitForm()">Submit</a>
                  </p>
    </form>
    Any help most apreciated

  2. #2

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,772
    Thank Post
    873
    Thanked 674 Times in 443 Posts
    Rep Power
    503
    I think you will need to use something like ASP/ASPX or PHP to acheive this - dont think it can be done via HTML/JScript

  3. Thanks to Gatt from:

    glennda (9th February 2010)

  4. #3

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,821
    Thank Post
    272
    Thanked 1,140 Times in 1,036 Posts
    Rep Power
    350
    im guessing i need to change the
    HTML Code:
    <a href="javascript: SubmitForm()">Submit</a>
    I know i will need to add an action into the
    HTML Code:
    <form name"dataform" method="post" action="submit.php">
    or something similar, but i don't have a clue/have never used PHP or ASP.

    do you know what i need to put in a PHP/asp Script to make it work?

  5. #4

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,772
    Thank Post
    873
    Thanked 674 Times in 443 Posts
    Rep Power
    503

  6. Thanks to Gatt from:

    glennda (9th February 2010)

  7. #5

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,821
    Thank Post
    272
    Thanked 1,140 Times in 1,036 Posts
    Rep Power
    350
    Fantastic thanks for your help, it now works!

    Toby

  8. #6

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,821
    Thank Post
    272
    Thanked 1,140 Times in 1,036 Posts
    Rep Power
    350
    I have now managed to break it! by trying to update it to my own needs,

    I have edited the PHP file so that it reads
    PHP Code:
    <?php
      $email 
    $_REQUEST['email'] ;
      
    $studentname $_REQUEST['StudentsName'] ;
      
    $parentname $_REQUEST['parentsname'] ;
      
    $studentdob $_REQUEST['DOBStudent'] ;
      
    $needforchange $_REQUEST['needforchange'] ;
      
    $furtherinfo $_REQUEST['furtherinfo'] ;
      
    mail"user@domain.com""Parent Update Form",
        
    $studentname$parentname$email$studentdob$needforchange$furtherinfo"From: $email) ;
      
    header"Location: /Test/thankyou.html" );
    ?>
    I have added the extra requests and put in my email address, but i don't seem to be getting the actual email, although it is going though the script seems to be running fine.

    but as far as i can see it is correct

    this is what i have editied
    PHP Code:
    <?php
      $email 
    $_REQUEST['email'] ;
      
    $message $_REQUEST['message'] ;

      
    mail"yourname@example.com""Feedback Form Results",
        
    $message"From: $email);
      
    header"Location: http://www.example.com/thankyou.html" );
    ?>

  9. #7

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,821
    Thank Post
    272
    Thanked 1,140 Times in 1,036 Posts
    Rep Power
    350
    Quote Originally Posted by glennda View Post
    Fantastic thanks for your help, it now works!

    Toby
    I jumped th gun abit with this!

  10. #8

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Something like this will work. First block is your data entry page, second is submit.php

    I think the only real problem was that you were trying to send multiple chunks in the email and you can't - there has to be 1 item for sender, 1 for subject, 1 for message body, 1 for other headers so what you do is join them together (today's big word: concatenate :-)) and in PHP this is done with the "."

    The other changes I've done are just a bit cosmetic - the "\t" character inserts a tab; the "\n " a new line. That works nicely in the plain text email but not on the web page so the final bit replaces the \n characters with HTML breaks (<br>)

    One of the reasons I rarely use PHP is that I find it harder to debug than ASP or ASP.Net - the default settings seem to be that the page just completely dies if there are any errors (even just a missing ; right at the end!) whereas ASP etc will run to the error point so at least you've got a fighting chance!


    Code:
    <html>
    <head>
    <title>Update Info</title>
    </head>
    
    <body>
    <form name="form1" action="submit.php" method="post">
      <p>Student Name: <input type="text" name="studentname" /></p>
      <p>Your Name: <input type="text" name="parentname" /> </p>
      <p>Contact Email: <input type="text" name="email" /></p>
      <p>DOB of Student: <input type="text" name="DOBStudent" /></p>
      <p>Details to be Updated:</p>
      <p><input type="radio" name="dataforchange" value="Email address" />Email Address</p>
      <p><input type="radio" name="dataforchange" value="home address" /> Home Address  </p>
      <p><input type="radio" name="dataforchange" value=" make wicki work" />I am only doing this so that you have to work lots!</p>
      <p>Please give further details here:</p>
      <p>
        <textarea name="furtherinfo" cols="100" rows="5">Please Provide Further Information Here</textarea>
      </p>
      <input type="submit" label="Submit"/>
    
    </form>
    </body>
    </html>
    Code:
    <html>
    <head>
    <title>Thanks</title>
    </head>
    <body>
    <h1>Thank you for your information</h1>
    <?php
      $email = $_REQUEST['email'] ;
      $studentname = $_REQUEST['studentname'] ;
      $parentname = $_REQUEST['parentname'] ;
      $studentdob = $_REQUEST['DOBStudent'] ;
      $needforchange = $_REQUEST['dataforchange'] ;
      $furtherinfo = $_REQUEST['furtherinfo'] ;
    
      $body=$body."student:\t".$studentname."\n";
      $body=$body."DOB:\t".$studentdob."\n";
      $body=$body."Reason:\t".$needforchange."\n";
      $body=$body."Info:\t".$furtherinfo."\n";
    
      $headers="From:".$email;
    
      mail( "testemail@testemail.com", "Parent Update Form",$body,$headers) ;
      echo str_replace("\n","<br>",$body);
    ?>
    
    <p>This has now been submitted</p>
    </body>
    </html>

  11. Thanks to srochford from:

    glennda (10th February 2010)

  12. #9

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,821
    Thank Post
    272
    Thanked 1,140 Times in 1,036 Posts
    Rep Power
    350
    Thanks, I will give it a try, but unfortuantly our web host seems to have removed my write permissions to out webserver root! so i cannot test it yet!

  13. #10

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,821
    Thank Post
    272
    Thanked 1,140 Times in 1,036 Posts
    Rep Power
    350
    Its working!! now i think i stop tweaking it! It does what I need it to do, only cosmetic changes!

SHARE:
+ Post New Thread

Similar Threads

  1. VBA Code to copy all form updates to one form
    By acrobson in forum Coding
    Replies: 2
    Last Post: 27th January 2010, 07:04 PM
  2. Frontpage form - submitting to a databas
    By papakura in forum Web Development
    Replies: 8
    Last Post: 24th January 2007, 09:06 AM
  3. Form with Auto Response
    By faza in forum Scripts
    Replies: 6
    Last Post: 10th January 2006, 03:41 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •