Jump to content

Contact form coded for Yahoo! Small Biz hosting using drop down box! Help!


imprezzy

Recommended Posts

So, I'm stumped. Stupid Yahoo! hosting has some silly requirements for PHP forms. I'm a PHP beginner, so bare with me. So far, I've figured out the usual input text fields for people to type in information such as name, phone number, comments, etc.  I also figured out how to insert a check box for people to check if they want our newsletter. Now, I want a drop down box with 4-5 options, but I haven't found a way to code it to work with this set of code I got from http://www.webmaster-showcase.net/response.php. The whole "echo" thing and the way it's done, I'm terribly confused. I wanted the drop down menu to be located below the phone number text input field. I know how to do drop down menus just for navigation purposes, but I've never coded it to be formatted for webmaster-showcase.net's Yahoo! requirement-based PHP form code.

 

The whole Yahoo thing is explained on http://www.webmaster-showcase.net/yahoo/SendMail.php under "Web Hosting Quirks".

 

Help please? =)  Thanks in advance!

 

Here's what I have so far.

 

<html>
<head>
        <title>Response</title>
</head>
<body background="images/bg.gif" bgcolor="#FFFFFF" link="#0000FF" vlink="#000099" text="#000000">

<table border=0 cellspacing=0 cellpadding=0 width=600>
<tr valign="top" align="left">
    <td><img src="images/c.gif" height=1 width="80"></td>
    <td><img src="images/c.gif" height=1 width="250"></td>
    <td><img src="images/c.gif" height=1 width="250"></td>
    <td><img src="images/c.gif" height=1 width="20"></td>
</tr>
<tr valign="top">
    <td colspan=1 height="58" align="center" valign="middle"></td>
    <td valign="middle" align="center" colspan="1" rowspan=1 width=164><font face="Arial Black" size="+1"><span style="font-size:18">Webmaster-Showcase.net</span></font></td>
    <td valign="middle" align="center" colspan="1" rowspan=1 width=164><font face="Arial Black" size="+1"><span style="font-size:18">Feedback</span></font></td>
</tr>
<tr valign="top">
  <td colspan="1"></td>
  <td colspan="2">
    <table><tr><td>
     
<?php
# ATTENTION! - IF YOU COPY THIS CODE, CHANGE THE NEXT LINE!
$to = "[email protected]";
$ask = 0;
if (($Name == "") && ($Email == "") && ($Phone == "") && ($Newsletter == "") && ($Comments == ""))
{
  $ask = 1;
  echo "<p class=\"bodymd\">Please fill out the form and then click on the submit button.</p>";
}
elseif (($Name == "") || ($Comments == ""))
{
  $ask = 1;
  echo "<p class=\"bodymd\">You missed some field.</p>";
}
if ($ask == 1)
{
  echo "<p class=\"bodymd\">Please fill in all the fields, so we can get back to you...</p>";
  echo "<form name=\"form\" method=\"post\" action=\"contact_test.php\">";
  echo "<p class=\"bodymd\">Your Name<br><input type=\"text\" name=\"Name\" value=\"$Name\"></p>";
  echo "<p class=\"bodymd\">Your Email<br><input type=\"text\" name=\"Email\" value=\"$Email\"></p>";
  echo "<p class=\"bodymd\">Your Phone Number<br><input type=\"text\" name=\"Phone\" value=\"$Phone\"></p>";

  echo "<p class=\"bodymd\">Comments or Questions<br><textarea name=\"Comments\" rows=\"5\" cols=\"50\">$Comments</textarea></p>";
  echo "<p class=\"bodymd\">Sign Up For Our Newsletter!<br><input type=\"checkbox\" name=\"Newsletter\" value=\"$Newsletter\">Yes</p>"; 
  echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\">";
  echo "<input type=\"reset\" name=\"Reset\" value=\"Clear Form\">";
  echo "</form>";
}
else
{
    $message = "Name: $Name\nEmail: $Email\nComments: $Comments\n";
    $eLog="/tmp/mailError.log";
    //Get the size of the error log
    //ensure it exists, create it if it doesn't
    $fh= fopen($eLog, "a+");
    fclose($fh);
    $originalsize = filesize($eLog);

    if (preg_match('/^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]{2,4}$/', $Email, $matches)) {
      print ("Sending to owner (cc: to you) --</ br></ br>");
      mail ($to, "Website Email", $message, "Cc:$Email");
    } else {
      print ("Sending to owner --</ br></ br>");
      mail ($to, "Website Email", $message);
    }
    /*
     * NOTE: PHP caches file status so we need to clear
     * that cache so we can get the current file size
     */
    clearstatcache();
    $finalsize = filesize($eLog);

    //Check if the error log was just updated
    if ($originalsize != $finalsize) {
      print "<p>There was a problem sending the mail. Please try again later or send the message to<a href=\"$to\">$to</a> using your own mail client progam.</p>";
    } else {
      echo "<p class=bodymd>Thanks for your message, $Name.</p>";
    }
}

?> 

Okay, I know these are the fields as well as the "Submit" and "Clear" buttons used in the form.

 

{
  echo "<p class=\"bodymd\">Please fill in all the fields, so we can get back to you...</p>";
  echo "<form name=\"form\" method=\"post\" action=\"contact_test.php\">";
  echo "<p class=\"bodymd\">Your Name<br><input type=\"text\" name=\"Name\" value=\"$Name\"></p>";
  echo "<p class=\"bodymd\">Your Email<br><input type=\"text\" name=\"Email\" value=\"$Email\"></p>";
  echo "<p class=\"bodymd\">Your Phone Number<br><input type=\"text\" name=\"Phone\" value=\"$Phone\"></p>";

  echo "<p class=\"bodymd\">Comments or Questions<br><textarea name=\"Comments\" rows=\"5\" cols=\"50\">$Comments</textarea></p>";
  echo "<p class=\"bodymd\">Sign Up For Our Newsletter!<br><input type=\"checkbox\" name=\"Newsletter\" value=\"$Newsletter\">Yes</p>"; 
  echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\">";
  echo "<input type=\"reset\" name=\"Reset\" value=\"Clear Form\">";
  echo "</form>";
}
else
{

 

How do I format a field that's a drop down menu using that "echo" method used for the other existing fields? I've tried giving it "input type=\"select"\", then gave it a name and  value just like I would with the rest of the fields. However, I have no idea where I would put the options for the drop down menu. I've tried the whole <option value> song and dance, but all it did was cause the PHP file to appear blank. I've even typed in a "data=" (then list the option values separated by commas) line between the input type and value tags within that echo code. I kept getting a blank page. I've looked for hours for a solution. Please help? Thanks!

Also, where in this code and how do I modify how the e-mail sent back to us is formatted with the information we need?  Or is that taken care of?

 

{
    $message = "Name: $Name\nEmail: $Email\nComments: $Comments\n";
    $eLog="/tmp/mailError.log";
    //Get the size of the error log
    //ensure it exists, create it if it doesn't
    $fh= fopen($eLog, "a+");
    fclose($fh);
    $originalsize = filesize($eLog);

    if (preg_match('/^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]{2,4}$/', $Email, $matches)) {
      print ("Sending to owner (cc: to you) --</ br></ br>");
      mail ($to, "Website Email", $message, "Cc:$Email");
    } else {
      print ("Sending to owner --</ br></ br>");
      mail ($to, "Website Email", $message);
    }

 

Do I just add another "&& ($NameOfField == "")" in the beginning of this code below under "$ask= 0;" and it'll be included in the order they're listed in that line of code? Will that take care of what information is sent back to us when a visitor to our site fills out the form?

 

<?php
# ATTENTION! - IF YOU COPY THIS CODE, CHANGE THE NEXT LINE!
$to = "[email protected]";
$ask = 0;
if (($Name == "") && ($Email == "") && ($Phone == "") && ($Newsletter == "") && ($Comments == ""))
{
  $ask = 1;
  echo "<p class=\"bodymd\">Please fill out the form and then click on the submit button.</p>";
}
elseif (($Name == "") || ($Comments == ""))
{
  $ask = 1;
  echo "<p class=\"bodymd\">You missed some field.</p>";
}
if ($ask == 1)
{

 

Much help is appreciated!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.