Closed Thread
Results 1 to 6 of 6

Thread: Need Help With a Script

  1. #1
    tfusion's Avatar
    tfusion is offline Learning Programmer
    Join Date
    Jan 2007
    Posts
    45
    Rep Power
    0

    Need Help With a Script

    Hello, Im working on a site(GoldWriters Home) I need a mailing form for the ordering page(www.goldwriters.info/order.php).
    The problem is that my mail form file isnt working. I have it included in order.php but doesnt work, i need someone to help me fix the code or find the error.

    HTML SCRIPT:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <body>

    PHP SCRIPT:

    Code:
    <?php
    #########################
    ##Goldwriters Mail Form##
    ####By Tfusion(Admin)####
    #########################

    //Vars Declaration
    $adminemail "orders@goldwriters.info";
    $name $_POST["name"];
    $email $_POST["email"];
    $plan $_POST["plan"];
    $message $_POST["message"];

    //Error Checking
    if ($name == "") {
    include 
    "mailform.php";
    echo 
    "Please write your contact name\n";
    }

    if (
    $email == "") {
    include 
    "mailform.php";
    echo 
    "Please write your contact email\n";
    }

    if (
    $plan == "") {
    include 
    "mailform.php";
    echo 
    "Please specify the plan you want\n";
    }

    if (
    $message == "") {
    include 
    "mailform.php";
    echo 
    "Please write what you need, your site link, etc\n";
    }

    //Mail Content
    $mailcontent"New writing order at Gold Writers with the following info:\n
    ----------------------------------------------\n
    Name: $name\n
    Email: $email\n
    Requested Plan: $plan\n
    ----------------------------------------------\n
    The Message Was:\n
    $message\n
    ----------------------------------------------\n
    Generated By GoldWriters Mail Script\n
    ----------------------------------------------\n"
    ;

    //Email Sending
    if ($submit) {
    mail ("$adminemail""Writing Order"$mailcontent);
    }
    ?>

    HTML SCRIPT:

    HTML Code:
    <center>
    <table border="0" cellpadding="0" cellspacing="0">
    <form method="post">
           <tr>
               <td>
                   <font size="2" face="Verdana"><b>Name<font color="#FF0000">*</font>:</b></font>
             </td>
               <td width="182">
                   <input type="text" name="name" value="" size="30" maxlength="40">
             </td>
           </tr>
           <tr>
               <td>
                   <font size="2" face="Verdana"><b>E-Mail Address<font color="#FF0000">*</font>:</b></font>
                   </td>
               <td>
                   <input type="text" name="email" value="" size="30" maxlength="50">
                   </td>
           </tr>
           <tr>
               <td>
                   <font size="2" face="Verdana"><b>Plan<font color="#FF0000">*</font>:</b></font>
    			   <br /> If you dont know what to put, <a href="plans.php">Check here</a>
                   </td>
               <td>
                   <input type="text" name="plan" value="" size="30" maxlength="40">
                   </td>
           </tr>
           <tr>
               <td colspan="2">
                   <font size="2" face="Verdana"><b>Extra Info<font color="#FF0000">*</font>:</b></font>
    			   <br />Plase include your site link, instructions, etc.
                   </td>
           </tr>
           <tr>
                <td colspan="2">
                    <textarea rows="10" cols="50" name="message" maxlength="500"></textarea>
                    </td>
           </tr>
           <tr>
               <td colspan="2">
                   <input type="reset" value="Reset">
                   <input type="submit" name="submit" value="Send Information">
                   </td>
           </tr>
           <tr>
               <td colspan="2" align="center">
                   <font size="2" face="Verdana"><font color="#FF0000">*</font> Required </font>
                   </td>
           </tr>
    	   </form>
    </table>
    </center>
    </body>
    </html>
    Thanks

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    If you could be a little more specific than its "not working" I could help you. In the mean time, you can have a look at this tutorial mail() function

  4. #3
    tfusion's Avatar
    tfusion is offline Learning Programmer
    Join Date
    Jan 2007
    Posts
    45
    Rep Power
    0
    Thanks for the tut, but i already know how to use the mail function.
    The problem is that the mail form isnt showing in the page, its not that is not included well, its that something is wrong with the script because it wont open if i open mailform.php in my browser.

  5. #4
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    Well you kind of have me confused how you posted your code. Which code is mainform.php and which order.php?

    Also, its better to use the isset() function to test if variables are empty/nonempty. So a better way would be to do

    Code:
    if (!isset($name)) {
    include 
    "mailform.php";
    echo 
    "Please write your contact name\n";

    And as a side note, I usually like to do form validation in JavaScript, it saves a lot submissions/checks/redirects.

  6. #5
    tfusion's Avatar
    tfusion is offline Learning Programmer
    Join Date
    Jan 2007
    Posts
    45
    Rep Power
    0
    I havent included the order.php file here, what i posted is all the mailform.php script... Thanks for that... i tested out but the form still not showing

  7. #6
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    Oh well I think the problem is, your including mailform.php infinity times.

    Essentially what happens is
    1) You load mailform.php
    2) It checks and sees that $name == ""
    3) Loads mailform.php
    4) It checks and sees that $name == ""
    5) Loads mailform.php again
    6) It checks and sees that $name == ""
    7) Loads mailform.php again
    and so on

    Until the max amount of memory for php is reached and it then fails

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to add a VAR to my PHP script?
    By dellee in forum PHP Development
    Replies: 6
    Last Post: 10-16-2011, 09:50 AM
  2. [HELP] convert Perl script to Bash shell script
    By Egypte in forum Linux Programming and Scripting
    Replies: 2
    Last Post: 04-24-2011, 05:37 PM
  3. In need of a script
    By lewje007 in forum PHP Development
    Replies: 5
    Last Post: 11-26-2009, 01:25 PM
  4. PHP script writing a PHP script
    By ezcat in forum PHP Development
    Replies: 6
    Last Post: 03-08-2009, 04:47 AM
  5. What is the difference between VB script and Java script?
    By newage123 in forum JavaScript and CSS
    Replies: 8
    Last Post: 11-14-2008, 10:49 AM

Tags for this Thread

Bookmarks

Posting Permissions

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