Jump to content


Photo

can't get this script to run


  • Please log in to reply
12 replies to this topic

#1 troll2555

troll2555
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 11 August 2006 - 03:11 PM

Can some one PLEASE tell me why this php script won't run on my site

You can see the html at http://www.vmwarts.com/we_buy_Form.htm


Here's the php I am using....

<?php
// Website Contact Form Generator
// http://www.tele-pro....s/contact_form/
// This script is free to use as long as you 
// retain the credit link 

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "sales@vmwarts.com";
$Subject = "I want to sell a book";
$LastName = Trim(stripslashes($_POST['LastName']));
$FirstName = Trim(stripslashes($_POST['FirstName']));
$Street1 = Trim(stripslashes($_POST['Street1']));
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Province = Trim(stripslashes($_POST['Province']));
$Country = Trim(stripslashes($_POST['Country']));
$HomeTel = Trim(stripslashes($_POST['HomeTel']));
$Title = Trim(stripslashes($_POST['Title']));
$Author = Trim(stripslashes($_POST['Author']));
$Publisher = Trim(stripslashes($_POST['Publisher']));
$Date = Trim(stripslashes($_POST['Date']));
$Cover = Trim(stripslashes($_POST['Cover']));
$Price = Trim(stripslashes($_POST['Price']));
$Condition = Trim(stripslashes($_POST['Condition']));

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (Trim($LastName)=="") $validationOK=false;
if (Trim($FirstName)=="") $validationOK=false;
if (Trim($Country)=="") $validationOK=false;
if (Trim($Title)=="") $validationOK=false;
if (Trim($Author)=="") $validationOK=false;
if (Trim($Publisher)=="") $validationOK=false;
if (Trim($Date)=="") $validationOK=false;
if (!is_numeric($Date)) $validationOK=false;
if (Trim($Cover)=="") $validationOK=false;
if (Trim($Price)=="") $validationOK=false;
if (!is_numeric($Price)) $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}



// prepare email body text
$Body = "";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "Street1: ";
$Body .= $Street1;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "State: ";
$Body .= $State;
$Body .= "\n";
$Body .= "Province: ";
$Body .= $Province;
$Body .= "\n";
$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";
$Body .= "HomeTel: ";
$Body .= $HomeTel;
$Body .= "\n";
$Body .= "Title: ";
$Body .= $Title;
$Body .= "\n";
$Body .= "Author: ";
$Body .= $Author;
$Body .= "\n";
$Body .= "Publisher: ";
$Body .= $Publisher;
$Body .= "\n";
$Body .= "Date: ";
$Body .= $Date;
$Body .= "\n";
$Body .= "Cover: ";
$Body .= $Cover;
$Body .= "\n";
$Body .= "Price: ";
$Body .= $Price;
$Body .= "\n";
$Body .= "Cover: ";
$Body .= $Cover;
$Body .= "\n";
$Body .= "Condition: ";
$Body .= $Condition;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=ThankYou.htm\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>



#2 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 11 August 2006 - 05:38 PM

Why are you trimming twice?
and you sure have a really difficult, complicated way of writing PHP
I am a PHP Guru, ask me questions if you want to

#3 xAtlas

xAtlas
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 11 August 2006 - 05:51 PM

what happens when you test the script? Are you getting errors? If so, can you post them?

#4 troll2555

troll2555
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 11 August 2006 - 06:27 PM

I'm not getting errors per se

when i post it via the web page, it goes to the contact5.php and shows a blank page and nothing comes across via the email..



#5 xAtlas

xAtlas
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 11 August 2006 - 06:42 PM

You do have a thankyou.html page right?

#6 troll2555

troll2555
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 11 August 2006 - 06:47 PM

I do...

ThankYou.htm

#7 troll2555

troll2555
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 11 August 2006 - 07:07 PM

I am actually only trying to do what I initally thought was a simple contact form on my web page. There are thousands of contact me pages out there, but I can't seem to find any that will either work on my site. For some reason, this has become immensely complicated. 

Research 'seemed" to indicate that php was the only way to go on this as a simple email me would not give my customer the ability to see what information I needed to make an offer to buy his book.

Please, someone tell me how to beat this thing.  It is the last item I need so I can get back to the business of selling books, and out of the part about web page building.

Yes, I am begging here for help, but I have been working on this for a week now and it is draining me.



#8 xAtlas

xAtlas
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 11 August 2006 - 07:13 PM

I do...

ThankYou.htm


Is the the ThankYou.htm in the home directory of the script?
Can you do me a favor? post the HTM portion of this script. Make sure that this is correct:

<form method="POST" action="contact.php">

action="contact.php" or whatever you named the PHP file to. I just tested this and it works fine now. It did the same thing as your because the 'action=' wasn't contact.php (which is what I had generated).

#9 troll2555

troll2555
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 11 August 2006 - 07:25 PM

changed to full url on them and tried again  still get a blank page pointing to http://www.vmwarts.com/contact5.php

#10 xAtlas

xAtlas
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 11 August 2006 - 07:27 PM

Can you do me a favor? post the HTM portion of this script. Make sure that this is correct:

<form method="POST" action="contact.php">

action="contact.php" or whatever you named the PHP file to. I just tested this and it works fine now. It did the same thing as your because the 'action=' wasn't contact.php (which is what I had generated).

#11 troll2555

troll2555
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 12 August 2006 - 01:17 AM

Okay

Here's the html portion of the Form page

<form method="POST" action="http://www.vmwarts.c.../contact5.php">

<p><font size="2">Your Email:* <br>
</font>
<input type="text" name="EmailFrom" size="20"><font size="2"> </font>
<p><font size="2">Last Name:* <br>
</font>
<input type="text" name="LastName" size="20"><font size="2"> </font>
<p><font size="2">First Name:* <br>
</font>
<input type="text" name="FirstName" size="20"><font size="2"> </font>
<p><font size="2">Street:<br>
</font>
<input type="text" name="Street1" size="20"><font size="2"> </font>
<p><font size="2">City:<br>
</font>
<input type="text" name="City" size="20"><font size="2"> </font>
<p><font size="2">State:<br>
</font>
<input type="text" name="State" size="20"><font size="2"> </font>
<p><font size="2">Province:<br>
</font>
<input type="text" name="Province" size="20"><font size="2"> </font>
<p><font size="2">Country:* <br>
</font>
<input type="text" name="Country" size="20"><font size="2"> </font>
<p><font size="2">Home Phone:<br>
</font>
<input type="text" name="HomeTel" size="20"><font size="2"> </font>
<p>&nbsp;<p><b><span class="tiny">

<font face="Verdana" size="2" color="#800000">Information About Your Book:<br>
</font></span></b><font face="Verdana" size="2">Fields marked (*) are required
</font>

<p>&nbsp;<p><font size="2">Title:* <br>
</font>
<input type="text" name="Title" size="20"><font size="2"> </font>
<p><font size="2">Author:* <br>
</font>
<input type="text" name="Author" size="20"><font size="2"> </font>
<p><font size="2">Publisher:* <br>
</font>
<input type="text" name="Publisher" size="20"><font size="2"> </font>
<p><font size="2">Date:* <br>
</font>
<input type="text" name="Date" size="20"><font size="2"><p>
<p><font size="2">Cover:* <br>
</font>
<select size="1" name="Cover">
<option>Leather</option>
<option>Cloth</option>
<option>Paper Wraps</option>
<option>Other</option></select><font size="2"> </font>
<p>Price:* <br>
<input type="text" name="Price" size="20"><font size="2"> </font>
<p><font size="2">Condition:<br>
</font>
<input type="text" name="Condition" size="20"><font size="2"> </font>
<p style="text-align: center"><input type="submit" name="submit" value="Submit">
</form>


#12 troll2555

troll2555
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 12 August 2006 - 01:19 AM

and here is the php file

<?php
// Website Contact Form Generator
// http://www.tele-pro....s/contact_form/
// This script is free to use as long as you 
// retain the credit link 

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "sales@vmwarts.com";
$Subject = "I want to sell a book";
$LastName = Trim(stripslashes($_POST['LastName']));
$FirstName = Trim(stripslashes($_POST['FirstName']));
$Street1 = Trim(stripslashes($_POST['Street1']));
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Province = Trim(stripslashes($_POST['Province']));
$Country = Trim(stripslashes($_POST['Country']));
$HomeTel = Trim(stripslashes($_POST['HomeTel']));
$Title = Trim(stripslashes($_POST['Title']));
$Author = Trim(stripslashes($_POST['Author']));
$Publisher = Trim(stripslashes($_POST['Publisher']));
$Date = Trim(stripslashes($_POST['Date']));
$Cover = Trim(stripslashes($_POST['Cover']));
$Price = Trim(stripslashes($_POST['Price']));
$Condition = Trim(stripslashes($_POST['Condition']));

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (Trim($LastName)=="") $validationOK=false;
if (Trim($FirstName)=="") $validationOK=false;
if (Trim($Country)=="") $validationOK=false;
if (Trim($Title)=="") $validationOK=false;
if (Trim($Author)=="") $validationOK=false;
if (Trim($Publisher)=="") $validationOK=false;
if (Trim($Date)=="") $validationOK=false;
if (!is_numeric($Date)) $validationOK=false;
if (Trim($Cover)=="") $validationOK=false;
if (Trim($Price)=="") $validationOK=false;
if (!is_numeric($Price)) $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}



// prepare email body text
$Body = "";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "Street1: ";
$Body .= $Street1;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "State: ";
$Body .= $State;
$Body .= "\n";
$Body .= "Province: ";
$Body .= $Province;
$Body .= "\n";
$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";
$Body .= "HomeTel: ";
$Body .= $HomeTel;
$Body .= "\n";
$Body .= "Title: ";
$Body .= $Title;
$Body .= "\n";
$Body .= "Author: ";
$Body .= $Author;
$Body .= "\n";
$Body .= "Publisher: ";
$Body .= $Publisher;
$Body .= "\n";
$Body .= "Date: ";
$Body .= $Date;
$Body .= "\n";
$Body .= "Cover: ";
$Body .= $Cover;
$Body .= "\n";
$Body .= "Price: ";
$Body .= $Price;
$Body .= "\n";
$Body .= "Cover: ";
$Body .= $Cover;
$Body .= "\n";
$Body .= "Condition: ";
$Body .= $Condition;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.vmwarts.com/ThankYouOffer.htm\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.vmwarts.com/error.htm\">";
}
?>



#13 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 12 August 2006 - 02:05 AM

Uploaded both your files to my server. It works perfectly and sends me the email message.

There's something wrong with the mail set-up on your server. Contact your hosting service provider and ask.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users