Jump to content

Need Help With a Script

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
tfusion

tfusion

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
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:
<!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:

<?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:

<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
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
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 http://forum.codecal...l-function.html

#3
tfusion

tfusion

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
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.

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
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

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.

#5
tfusion

tfusion

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
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 :(

#6
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
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