PHP Form - PayPal Reward ???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bigtimenobody
Forum Newbie
Posts: 5
Joined: Sat Oct 22, 2005 9:42 am
Location: Canada

PHP Form - PayPal Reward ???

Post by bigtimenobody »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hello there,

I am trying to make a form that a person can fill out, and upon hitting send, the content of the form is emailed to me. I am new at this, and up to this point have only made simple forms that contain 4 variables. This one uses far more than that, and it utilizes a number of different input methods.

Here is my html...

Code: Select all

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Prestige Interactive - free quote form</title>

<style type="text/css">
<!--A:link {
text-decoration:none;
color: #FF0000;
} A:visited {
text-decoration:none;
color: #FF0000;
} A:active {
text-decoration:none;
color: #660000;
} A:hover {color:#909090}-->
</style>

<link href="../scripts/stylesheet_one.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>

<body>

<form action="../scripts/get_quote.php" method="post">
<table width="550" cellspacing="5">
<tr>
<td>
Contact Name</td>
</tr>
<tr>
<td >
<input name="name" type="text" size="50" maxlength="50" /></td>
</tr>
<tr>
<td>
Address</td>
</tr>
<tr>
<td>
<textarea name="address" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td>
Phone Number</td>
</tr>
<tr>
<td>
<input name="phone" type="text" size="15" maxlength="20" /></td>
</tr>
<tr>
<td>
Email</td>
</tr>
<tr>
<td>
<input name="email" type="text" size="40" maxlength="40" /></td>
</tr>
<tr>
<td>
Do you have a domain name? (eg. www.yourname.com)</td>
</tr>
<tr>
<td>
<input name="own_domain" type="radio" value="no" />no 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="own_domain" type="radio" value="yes" />yes</td>
</tr>
<tr>
<td>
Do you have a web service provider? (eg. a place where your site will be hosted)</td>
</tr>
<tr>
<td>
<input name="own_service_provider" type="radio" value="no" />no
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="own_service_provider" type="radio" value="yes" />yes</td>
</tr>

<tr>
<td>Do you need to have a business logo digitally designed?</td>
</tr>
<tr>
<td>
<input name="own_logo" type="radio" value="no" />
no
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="own_logo" type="radio" value="yes" />yes
</tr>
<tr>
<td>
Do you have images ready for use on your site?
</td>
</tr>
<tr>
<td>
<input name="own_images" type="radio" value="no" />no
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="own_images" type="radio" value="yes" />yes
</td>
</tr>
<tr>
<td>
Do you have your text ready?
</td>
</tr>
<tr>
<td>
<input name="own_text" type="radio" value="no" />
no
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="own_text" type="radio" value="yes" />yes
</td>
</tr>
<tr>
<td>
Would you like your site to use flash animation in its design? (see <a href="http://www.mcgibbysgolf.com" target="_blank"> McGibby's Golf</a> for an example)
</td>
</tr>
<tr>
<td>
<input name="need_flash" type="radio" value="no" />no
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="need_flash" type="radio" value="yes" />yes
</td>
</tr>
<tr>
<td>
List three sites that you'd like yours to be modelled after. (We want some ideas of what you like)
</td>
</tr>
<tr>
<td>
Site 1 - &nbsp;<input name="site_one" type="text" size="40" maxlength="40" />
<br />
Site 2 - &nbsp;<input name="site_two" type="text" size="40" maxlength="40" />
<br />
Site 3 - &nbsp;<input name="site_three" type="text" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td>
Who are your major competitors? (Please provide their url's if applicable)
</td>
</tr>
<tr>
<td>
Site 1 - &nbsp;<input name="competitor_one" type="text" id="competitor_one" size="40" maxlength="40" />
<br />
Site 2 - &nbsp;<input name="competitor_two" type="text" size="40" maxlength="40" />
<br />
Site 3 - &nbsp;<input name="competitor_three" type="text" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td>
How many pages will your completed site require? (Please include the home page)
</td>
</tr>
<tr>
<td>
<input name="pages" type="text" size="10" maxlength="10" />&nbsp; pages
</td>
</tr>
<tr>
<td>
When would you like the site to be completed. (Please be aware that a short time frame can result in a higher cost to you)
</td>
</tr>
<tr>
<td>
<input name="completion" type="text" size="10" maxlength="10" /> &nbsp;days

<tr>
<td>
What is your project budget? (<span class="style1">Canadian funds</span>)</td>
</tr>
<tr>
<td>
<select name="budget" class="input">
<option>Please select an amount.</option>
<option value="budget_one">$0.00 - $400.00</option>
<option value="budget_two">$400.00 - $800.00</option>
<option value="budget_three">$800.00 - $1 200.00</option>
<option value="budget_four">$1200.00 - $1 600.00 </option>
<option value="budget_five">$1 600.00 - $2 000.00</option>
<option value="budget_six">$2 000.00 - $2 500.00</option>
<option value="budget_seven">$2 500.00 - $3 000.00 </option>
<option value="budget_eight">$3 000.00 - $4 000.00 </option>
<option value="budget_nine">$4 000.00 +</option>
</select>
</td>
</tr>
<tr>
<td>
How are you going to update the site?
</td>
</tr>
<tr>
<td>
<select name="budget" class="input">
<option>Please select a method for updating your site.</option>
<option value="update_one">We would like Prestige Interactive to update the site.</option>
<option value="update_two">We would like to update the site ourselves.</option>
</select>
</td>
</tr>
<tr>
<td>
Please provide us with any additional comments that you might have.
</td>
</tr>
<tr>
<td>
<textarea name="additional_comments" cols="50" rows="5"></textarea>
</td>
</tr>
<tr>
<td>
<input type="reset" value="Reset">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="submit" value="Submit">
</td>
</tr>
</table>
</form>


</body>
</html>
Here is my PHP - this is where I am messed up.....

Code: Select all

<?php

$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';
$errors = '';


if ($name == '' || $address == '' || $phone == '' || $email == '' $own_domain == '' $own_service_provider == '' $own_logo == '' $own_images == '' $own_text == '' $need_flash == '' $site_one == '' $site_two == '' $site_three == '' $competitor_one == '' $competitor_two == '' $competitor_three == '' $pages == '' $completion == '' $budget == '' $update == '' $additional_comments == '')
{
$errors .= '<li>You did not enter one or more of the required fields. Please go back and try again.</li>';
}
if ($errors != '')
{
echo "<html><body>The following errors occured while processing your form.<ul>\n$errors</ul></body></html>";
} else {
$message = '';

$message .= "Name= $name\n";
$message .= "Address= $address\n";
$message .= "Phone= $phone\n";
$message .= "Email= $email\n";
$message .= "Do you have your own domain= $own_domain\n";
$message .= "Do you have your own service provider= $own_service_provider\n";
$message .= "Do you have your own logo= $own_logo\n"; 
$message .= "Do you have your images prepared= $own_images\n"; 
$message .= "Do you have your text prepared= $own_text\n"; 
$message .= "Do you want to include flash= $need_flash\n"; 
$message .= "Sites we like= $site_one\n"; 
$message .= "Sites we like= $site_two\n"; 
$message .= "Sites we like=$site_three\n"; 
$message .= "Our competitors site= $competitor_one\n"; 
$message .= "Our competitors site= $competitor_two\n"; 
$message .= "Our competitors site= $competitor_three\n"; 
$message .= "How many pages will you need= $pages\n"; 
$message .= "When would you like the site completed= $completion\n"; 
$message .= "What is your budget= $budget\n"; 
$message .= "Who will update your site= $update\n"; 
$message .= "Additional comments= $additional_comments\n"; 

$message = stripslashes($message);

// mail the form submit 
mail("gwhite@prestigeinteractive.com","Message from Prestige Interactive's Website requesting a pricing quote",$message, "From: <".$email.">");
header('Location: http://www.prestigeinteractive.com/mrwhite2/');
}

?>
Well I hope someone can help me out. If this takes you a ton of time to remedy, I apologize and would be willing to give you some incentive....

Thanks,

Greg :idea:


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your code assumes register_globals is on, is this true?

Run the following:

Code: Select all

echo '<pre>';
echo 'PHP Version: '.phpversion()."\n";
echo 'Display Errors: '.(ini_get('display_errors') == '1' ? 'On' : 'Off')."\n";
echo 'Error Level: '.(ini_get('error_reporting') == '2047' ? 'E_ALL' : 'Not E_ALL')."\n";
echo 'Register Globals: '.(ini_get('register_globals') == '' ? 'Off' : 'On')."\n";
echo '</pre>';
bigtimenobody
Forum Newbie
Posts: 5
Joined: Sat Oct 22, 2005 9:42 am
Location: Canada

Still Stuck with PHP

Post by bigtimenobody »

Hello there,
Sadly, I don't really know what you are telling me. I am obviously new at this.

Change all of those calls to variables to their $_POST equivilant....if register_globals is off..the way your doing it won't work. (eg: $_POST["own domain"]) -- and get rid of all but one of the $errors = ''; lines...your just doing the same thing repeatedly..which does nothing but waste lines of code.

On another site, I was told the above.
____________________
Here is my response to that....

I've changed the repetitive code for the $errors as you mentioned. I however, I am not sure what you mean when you say change all of those "calls" to "variables" to their "$_POST" equivalent.

I am also not sure how to tell if "register_globals" is off.

I am sorry about my lack of knowledge in this area, and am greatly appreciative of your willingness to help me out.

If you wouldn't mind taking a snippet of code and modifying it for me, then I could learn from that, that would be great.
________________________

Well I hope someone can help me out...I am still in a bind.

Later,
Greg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you run the code I posted in its own script you will get data about whether register globals are on, among various other settings..
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Your PHP is a bit strange. I assume it doesn't parse.

1. Why is $errors declared... err... a kazillion times setting it to an empty screen? Remove the extra declarations
2. You must have given up and stopped adding the || to the conditional. They need to be there for all of them.
3. Indentation would be nice.
4. You may want to reconsider letting anyone and everyone send emails. You could easily be hit by spambots.
bigtimenobody
Forum Newbie
Posts: 5
Joined: Sat Oct 22, 2005 9:42 am
Location: Canada

Post by bigtimenobody »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hey there,
You are right, i am getting a parse error.  As you can see I am new at this.  I have looked at some tutorials, but don't have a good grip on this, as you can see.  

I have made some changes now...and it looks like this:

Code: Select all

<?php
 
$errors = '';


if ($_POST["name"] == '' || $_POST["address"] == '' || $_POST["phone"] == '' || $_POST["email"] == '' $_POST["own_domain"] == '' $_POST["own_service_provider"] == '' $_POST["own_logo"] == '' $_POST["own_images"] == '' $_POST["own_text"] == '' $_POST["need_flash"] == '' $_POST["site_one"] == '' $_POST["site_two"] == '' $_POST["site_three"] == '' $_POST["competitor_one"] == '' $_POST["competitor_two"] == '' $_POST["competitor_three"] == '' $_POST["pages"] == '' $_POST["completion"] == '' $_POST["budget"] == '' $_POST["update"] == '' $_POST["additional_comments"] == '')
{
  $errors .= '<li>You did not enter one or more of the required fields. Please go back and try again.</li>';
}
if ($errors != '')
{
  echo "<html><body>The following errors occured while processing your form.<ul>\n$errors</ul></body></html>";
} else {
  $message = '';

  $message .= 'Name= '.$_POST["name"]."\n";
  $message .= 'Address= '.$_POST["address"]."\n"; 
  $message .= 'Phone= '.$_POST["phone"]."\n"; 
  $message .= 'Email= '.$_POST["email"]."\n";
  $message .= 'Do you have your own domain= '.$_POST["own_domain"]."\n";
  $message .= 'Do you have your own service provider= '.$_POST["own_service_provider"]."\n";
  $message .= 'Do you have your own logo= '.$_POST["own_logo"]."\n";
  $message .= 'Do you have your images prepared= '.$_POST["own_images"]."\n";
  $message .= 'Do you have your text prepared= '.$_POST["own_text"]."\n";
  $message .= 'Do you want to include flash= '.$_POST["need_flash"]."\n";
  $message .= 'Sites we like= '.$_POST["site_one"]."\n";
  $message .= 'Sites we like= '.$_POST["site_two"]."\n";
  $message .= 'Sites we like= '.$_POST["site_three"]."\n";
  $message .= 'Our competitors site= '.$_POST["competitor_one"]."\n";
  $message .= 'Our competitors site= '.$_POST["competitor_two"]."\n";
  $message .= 'Our competitors site= '.$_POST["competitor_three"]."\n";
  $message .= 'How many pages will you need= '.$_POST["pages"]."\n";
  $message .= 'When would you like the site completed= '.$_POST["completion"]."\n";
  $message .= 'What is your budget= '.$_POST["budget"]."\n";
  $message .= 'Who will update your site= '.$_POST["update"]."\n";
  $message .= 'Additional comments= '.$_POST["additional_comments"]."\n";

  $message = stripslashes($message);

  // mail the form submit 
  mail("gwhite@prestigeinteractive.com","Message from Prestige Interactive's Website requesting a pricing quote",$message,  "From: <".$email.">");
  header('Location: http://www.prestigeinteractive.com/mrwhite2');
}

?>
Any help in editting this code would be greatly appreciated. I am making small steps..hopefully in the right direction. I would like to safeguard myself from spambots, but I don't know how to do that.

Thanks for your imput. If you can help me fix it..that would be great. If not...thanks for the insights.

Later,

Greg


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
bigtimenobody
Forum Newbie
Posts: 5
Joined: Sat Oct 22, 2005 9:42 am
Location: Canada

Problem solved.....

Post by bigtimenobody »

Thanks people.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

It works?
bigtimenobody
Forum Newbie
Posts: 5
Joined: Sat Oct 22, 2005 9:42 am
Location: Canada

Got it..

Post by bigtimenobody »

Yeah...I finally got it to work. With some help from a friend.
Thanks though,
Greg
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Re: Got it..

Post by foobar »

bigtimenobody wrote:Yeah...I finally got it to work. With some help from a friend.
"With a little help from my friend"... daadadiddadaa... oh, sorry. :P
Post Reply