Jump to content


Photo

PHP Issue


  • Please log in to reply
13 replies to this topic

#1 7pm

7pm
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 09 March 2006 - 11:21 PM

Hey all!

Great site here, glad I signed up. I cannot figure out how to to do this.
I do the web work for a good friend of mine, and he asked me to add an
order form section to his site. You can see what i've done so far as for
the design and check out my html codes if you need here:
[a href=\"http://www.cajjmere.com/online/order.html\" target=\"_blank\"]http://www.cajjmere.com/online/order.html[/a]

Now i'm having BIG problems trying to get the PHP form to work. All he
wants, is for people to be able to goto the page, enter the quantity of
whatever items they want, enter their name, email and address, and hit
submit, and the results of that order get emailed to his web people. They
in turn send the person who ordered an email with payment instructions.

Can someone take a look at my PHP script and see what's wrong with it?
I know it needs the email info added but i've stumped on what codes to add.
I've copied it below. I would be SOOOO greatful if anyone can assist? This
is of an urgent nature now, i'm behind in wrapping it up. (took out the first and
last < > cuz i'm not sure if HTML is turned on in this forum.)

Thank you!!
Clark


html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>D'LISH-US MUSIC ONLINE STORE - CAJJMERE.COM</title>
</head>
<body style="font-family: Arial">
<h1><br>
D'LISH-US MUSIC ONLINE STORE</h1>
<br><br>

<?php
$qtyrun = $_POST['qtyrun'];
$qtyex = $_POST['qtyex'];
$qtylate = $_POST['qtylate'];
$qtyturn = $_POST['qtyturn'];
$name = $_POST['yourname'];
$email = $_POST['email'];
$address = $_POST['address'];
?>

<p>Thank you for shopping at D'Lish-Us!
<p>Your Order Is Being Processed.</p>
<p>You should receive an email with
full payment instructions within two hours.</p>
</body>
</html

#2 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 09 March 2006 - 11:28 PM

You may want to take a look at the mail() function.

[a href=\"http://ca3.php.net/manual/en/ref.mail.php\" target=\"_blank\"]http://ca3.php.net/manual/en/ref.mail.php[/a]

#3 7pm

7pm
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 09 March 2006 - 11:38 PM

[!--quoteo(post=353429:date=Mar 9 2006, 06:28 PM:name=Gaia)--][div class=\'quotetop\']QUOTE(Gaia @ Mar 9 2006, 06:28 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You may want to take a look at the mail() function.

[a href=\"http://ca3.php.net/manual/en/ref.mail.php\" target=\"_blank\"]http://ca3.php.net/manual/en/ref.mail.php[/a]
[/quote]


Hi Gaia, thank you for the link. I'm extremely brain dead with this tho. I looked over all
that and i'm too new to this to understand any of it. It reads like bad stereo instructions, LOL.
The codeing i've obtained thus far was just by copy and paste mode with a few alterations to
suit the site that i'm creating. That's why I need someone to look over my existing code
and tell me what needs to added and where by example.

#4 Flinch

Flinch
  • Members
  • PipPip
  • Member
  • 13 posts
  • Locationcomputer, house, USA

Posted 09 March 2006 - 11:39 PM

I just posted this in your duped topic:

Well, right now your script isn't doing anything, except gathering the vartiables. It needs to first do some data checking, you know, like making sure that no required input fields were left blank, and that the data entered in those input fields is legit and secure. You can mostly check these things with regular expressions, such as making sure it's a valid email address.

Next, after you've made sure that all the data entered is where it's supposed to be and correct, then you can send it via email using the mail() function.
[br][br][br][br]

#5 7pm

7pm
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 09 March 2006 - 11:49 PM

[!--quoteo(post=353436:date=Mar 9 2006, 06:39 PM:name=Flinch)--][div class=\'quotetop\']QUOTE(Flinch @ Mar 9 2006, 06:39 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I just posted this in your duped topic:

Well, right now your script isn't doing anything, except gathering the vartiables. It needs to first do some data checking, you know, like making sure that no required input fields were left blank, and that the data entered in those input fields is legit and secure. You can mostly check these things with regular expressions, such as making sure it's a valid email address.

Next, after you've made sure that all the data entered is where it's supposed to be and correct, then you can send it via email using the mail() function.
[/quote]


Thank you Flinch, however I do not know how to do any of those things I require someone to give me actual guidance by looking at my codes and telling what needs to be added, and where so I can copy and paste it over. This is not my forte really, hope you guys don't see me as some nut, lol.

#6 Flinch

Flinch
  • Members
  • PipPip
  • Member
  • 13 posts
  • Locationcomputer, house, USA

Posted 10 March 2006 - 12:01 AM

$qtyrun = $_POST['qtyrun'];
$qtyex = $_POST['qtyex'];
$qtylate = $_POST['qtylate'];
$qtyturn = $_POST['qtyturn'];
$name = $_POST['yourname'];
$email = $_POST['email'];
$address = $_POST['address'];


//START MY ADDITIONS//

if(!$name or !$email or !$address) {
  if(!$name) die("You did not enter your name!");
  if(!$email) die("You did not enter your email address!");
  if(!$address) die("You did not enter your address!");

}

//make sure the email is a valid one using a simple regular exp. i found at regexlib.com
if(!preg_match("#^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$#", $email) ) {
  
   die("This is not a valid email address!";
}

//use the simple function strip_tags() to clean out any html and JS from input
$name = strip_tags($name);
$address = strip_tags($address);


That's the simplest way to do all the form verification for the personal information. Sorry, I'm feeling a little lazy and I don't want to write out the entire script for you. :)
[br][br][br][br]

#7 7pm

7pm
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 March 2006 - 12:10 AM

[!--quoteo(post=353445:date=Mar 9 2006, 07:01 PM:name=Flinch)--][div class=\'quotetop\']QUOTE(Flinch @ Mar 9 2006, 07:01 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$qtyrun = $_POST['qtyrun'];
$qtyex = $_POST['qtyex'];
$qtylate = $_POST['qtylate'];
$qtyturn = $_POST['qtyturn'];
$name = $_POST['yourname'];
$email = $_POST['email'];
$address = $_POST['address'];
//START MY ADDITIONS//

if(!$name or !$email or !$address) {
  if(!$name) die("You did not enter your name!");
  if(!$email) die("You did not enter your email address!");
  if(!$address) die("You did not enter your address!");

}

//make sure the email is a valid one using a simple regular exp. i found at regexlib.com
if(!preg_match("#^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$#", $email) ) {
  
   die("This is not a valid email address!";
}

//use the simple function strip_tags() to clean out any html and JS from input
$name = strip_tags($name);
$address = strip_tags($address);
That's the simplest way to do all the form verification for the personal information. Sorry, I'm feeling a little lazy and I don't want to write out the entire script for you. :)
[/quote]


Awww thanks flinch! But don't feel lazy man, please help me out if you can?. I've placed that verification part where you showed me. Now it's the email part I guess that is left? I'm so screwed on this....

also i'm confused on the last part there, cuz i tried the form after copying that over by leaving the email blank for example and it didn't verify and tell me to go back.

#8 Flinch

Flinch
  • Members
  • PipPip
  • Member
  • 13 posts
  • Locationcomputer, house, USA

Posted 10 March 2006 - 12:17 AM

[!--quoteo(post=353447:date=Mar 9 2006, 07:06 PM:name=7pm)--][div class=\'quotetop\']QUOTE(7pm @ Mar 9 2006, 07:06 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Awww thanks flinch! But don't feel lazy man, please help me out if you can?. I've placed that verification part where you showed me. Now it's the email part I guess that is left? I'm so screwed on this....
[/quote]


Oh ok.....

$qtyrun = $_POST['qtyrun'];
$qtyex = $_POST['qtyex'];
$qtylate = $_POST['qtylate'];
$qtyturn = $_POST['qtyturn'];
$name = $_POST['yourname'];
$email = $_POST['email'];
$address = $_POST['address'];
//START MY ADDITIONS//

if(!$name or !$email or !$address) {
  if(!$name) die("You did not enter your name!");
  if(!$email) die("You did not enter your email address!");
  if(!$address) die("You did not enter your address!");

}

//make sure the email is a valid one using a simple regular exp. i found at regexlib.com
if(!preg_match("#^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$#", $email) ) {
  
   die("This is not a valid email address!";
}

//use the simple function strip_tags() to clean out any html and JS from input
$name = strip_tags($name);
$address = strip_tags($address);

//do some small variable handling
$qtyrun = ($qtyrun == "") ? "0" : $qtyrun;
$qtyex = ($qtyex == "") ? "0" : $qtyex;
$qtylate = ($qtylate == "") ? "0" : $qtylate;
$qtyturn = ($qtyturn == "") ? "0" : $qtyturn;

//The above four lines will substitute the string "0" into the quantity variables if they are left empty.

//make the body text that will be emailed
$body = "An order has been submitted by: {$name}.

They have requested the following quantities:

DLI001 RUNWAY EP: {$qtyrun}
DLI002 EXSTACY QUEEN: {$qtyex}
DLI003 LATE NITE EP: {$qtylate}
DLICD0602 TURNING IT: {$qtyturn}

The address specified was:

{$address}";

$subject = "Order form from {$name}";

mail("your_email@domain.com", $subject, $body, "From: {$email}");

//Order form sent!

echo "Your order has been recieved and will be processed shortly!  Thank you for your business!";


Okay, it's crude, and leaves a few holes in the security department, but it will work and do the job for what you need done. I haven't tested this myself, so if there are any parse errors, or any other problems, tell me and I'll fix them. Post back on your results! :)
[br][br][br][br]

#9 7pm

7pm
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 March 2006 - 12:22 AM

Well I copied that over and tried out the form and it didn't work for me ....that's odd.

Try it out Flinch. click here for the form -> [a href=\"http://www.cajjmere.com/online/order.html\" target=\"_blank\"]*FORM*[/a]

I tried, and it just gave me a clear white screen. this is my current code as you displayed to me.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>D'LISH-US MUSIC ONLINE STORE - CAJJMERE.COM</title>
</head>
<body style="font-family: Arial">
<h1><br>
D'LISH-US MUSIC ONLINE STORE</h1>
<br><br>

<?php
$qtyrun = $_POST['qtyrun'];
$qtyex = $_POST['qtyex'];
$qtylate = $_POST['qtylate'];
$qtyturn = $_POST['qtyturn'];
$name = $_POST['yourname'];
$email = $_POST['email'];
$address = $_POST['address'];
//START MY ADDITIONS//

if(!$name or !$email or !$address) {
if(!$name) die("You did not enter your name!");
if(!$email) die("You did not enter your email address!");
if(!$address) die("You did not enter your address!");

}

//make sure the email is a valid one using a simple regular exp. i found at regexlib.com
if(!preg_match("#^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$#", $email) ) {

die("This is not a valid email address!";
}

//use the simple function strip_tags() to clean out any html and JS from input
$name = strip_tags($name);
$address = strip_tags($address);

//do some small variable handling
$qtyrun = ($qtyrun == "") ? "0" : $qtyrun;
$qtyex = ($qtyex == "") ? "0" : $qtyex;
$qtylate = ($qtylate == "") ? "0" : $qtylate;
$qtyturn = ($qtyturn == "") ? "0" : $qtyturn;

//The above four lines will substitute the string "0" into the quantity variables if they are left empty.

//make the body text that will be emailed
$body = "An order has been submitted by: {$name}.

They have requested the following quantities:

DLI001 RUNWAY EP: {$qtyrun}
DLI002 EXSTACY QUEEN: {$qtyex}
DLI003 LATE NITE EP: {$qtylate}
DLICD0602 TURNING IT: {$qtyturn}

The address specified was:

{$address}";

$subject = "Order form from {$name}";

mail("orders@cajjmere.com", $subject, $body, "From: {$email}");

//Order form sent!

echo "Your order has been recieved and will be processed shortly! Thank you for your business!";
?>
</body>
</html>

#10 Flinch

Flinch
  • Members
  • PipPip
  • Member
  • 13 posts
  • Locationcomputer, house, USA

Posted 10 March 2006 - 12:45 AM

Okay, I ran this on my local server, and despite some notice errors (that won't affect you in runtime), I found only one parser error (forget to close the die() function on line 86), and fixed it. Try this:

$qtyrun = $_POST['qtyrun'];
$qtyex = $_POST['qtyex'];
$qtylate = $_POST['qtylate'];
$qtyturn = $_POST['qtyturn'];
$name = $_POST['yourname'];
$email = $_POST['email'];
$address = $_POST['address'];
//START MY ADDITIONS//

if(!$name or !$email or !$address) {
if(!$name) die("You did not enter your name!");
if(!$email) die("You did not enter your email address!");
if(!$address) die("You did not enter your address!");

}

//make sure the email is a valid one using a simple regular exp. i found at regexlib.com
if(!preg_match("#^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$#", $email) ) {

die("This is not a valid email address!");
}

//use the simple function strip_tags() to clean out any html and JS from input
$name = strip_tags($name);
$address = strip_tags($address);

//do some small variable handling
$qtyrun = ($qtyrun == "") ? "0" : $qtyrun;
$qtyex = ($qtyex == "") ? "0" : $qtyex;
$qtylate = ($qtylate == "") ? "0" : $qtylate;
$qtyturn = ($qtyturn == "") ? "0" : $qtyturn;

//The above four lines will substitute the string "0" into the quantity variables if they are left empty.

//make the body text that will be emailed
$body = "An order has been submitted by: {$name}.

They have requested the following quantities:

DLI001 RUNWAY EP: {$qtyrun}
DLI002 EXSTACY QUEEN: {$qtyex}
DLI003 LATE NITE EP: {$qtylate}
DLICD0602 TURNING IT: {$qtyturn}

The address specified was:

{$address}";

$subject = "Order form from {$name}";

mail("cajjmerewray@rogers.com", $subject, $body, "From: {$email}");

//Order form sent!

echo "Your order has been recieved and will be processed shortly! Thank you for your business!";

[br][br][br][br]

#11 7pm

7pm
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 March 2006 - 12:58 AM

SUCCESS!!

It worked! Very cool. So lemme ask you Flinch. In the future when products are being added to the catalogue
I assume that it would be added to these sections below. (using the word EXAMPLE often)

$qtyrun = $_POST['qtyrun'];
$qtyex = $_POST['qtyex'];
$qtylate = $_POST['qtylate'];
$qtyturn = $_POST['qtyturn'];
[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$qtyEXAMPLE1 = $_POST['EXAMPLE1'];
$qtyEXAMPLE2 = $_POST['EXAMPLE2'];[!--colorc--][/span][!--/colorc--]
$name = $_POST['yourname'];
$email = $_POST['email'];
$address = $_POST['address'];
//START MY ADDITIONS//

//do some small variable handling
$qtyrun = ($qtyrun == "") ? "0" : $qtyrun;
$qtyex = ($qtyex == "") ? "0" : $qtyex;
$qtylate = ($qtylate == "") ? "0" : $qtylate;
$qtyturn = ($qtyturn == "") ? "0" : $qtyturn;
[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$qtyEXAMPLE1 = ($qtyEXAMPLE1 == "") ? "0" : $qtyEXAMPLE1;
$qtyEXAMPLE2 = ($qtyEXAMPLE2 == "") ? "0" : $qtyEXAMPLE2;[!--colorc--][/span][!--/colorc--]


They have requested the following quantities:

DLI001 RUNWAY EP: {$qtyrun}
DLI002 EXSTACY QUEEN: {$qtyex}
DLI003 LATE NITE EP: {$qtylate}
DLICD0602 TURNING IT: {$qtyturn}
[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]EXAMPLE EXAMPLE1: {$qtyEXAMPLE1}
EXAMPLE EXAMPLE2: {$qtyEXAMPLE2}[!--colorc--][/span][!--/colorc--]

Correct?

#12 Flinch

Flinch
  • Members
  • PipPip
  • Member
  • 13 posts
  • Locationcomputer, house, USA

Posted 10 March 2006 - 01:07 AM

Indeed. Just like that. :)

But, as your catalogue gets bigger, I would suggest implementing a database to make your job easier. PHP and MySQL (when used correctly) can be a powerful and will saw through any project you might need done.
[br][br][br][br]

#13 7pm

7pm
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 March 2006 - 01:12 AM

[!--quoteo(post=353471:date=Mar 9 2006, 08:07 PM:name=Flinch)--][div class=\'quotetop\']QUOTE(Flinch @ Mar 9 2006, 08:07 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Indeed. Just like that. :)

But, as your catalogue gets bigger, I would suggest implementing a database to make your job easier. PHP and MySQL (when used correctly) can be a powerful and will saw through any project you might need done.
[/quote]

[!--sizeo:3--][span style=\"font-size:12pt;line-height:100%\"][!--/sizeo--]AWESOME!![!--sizec--][/span][!--/sizec--]
Many Thanks Flinch you are the best!! The record label thanks you also!


#14 Flinch

Flinch
  • Members
  • PipPip
  • Member
  • 13 posts
  • Locationcomputer, house, USA

Posted 10 March 2006 - 01:22 AM

[!--quoteo(post=353474:date=Mar 9 2006, 08:12 PM:name=7pm)--][div class=\'quotetop\']QUOTE(7pm @ Mar 9 2006, 08:12 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
[!--sizeo:3--][span style=\"font-size:12pt;line-height:100%\"][!--/sizeo--]AWESOME!![!--sizec--][/span][!--/sizec--]
Many Thanks Flinch you are the best!! The record label thanks you also!

[/quote]

No problem. Glad to help someone in need!
[br][br][br][br]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users