Jump to content

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/
Share on other sites

[!--quoteo(post=353429:date=Mar 9 2006, 06:28 PM:name=Gaia)--][div class=\'quotetop\']QUOTE(Gaia @ Mar 9 2006, 06:28 PM) [snapback]353429[/snapback][/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.
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15952
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15955
Share on other sites

[!--quoteo(post=353436:date=Mar 9 2006, 06:39 PM:name=Flinch)--][div class=\'quotetop\']QUOTE(Flinch @ Mar 9 2006, 06:39 PM) [snapback]353436[/snapback][/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.
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15958
Share on other sites

[code]
$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);
[/code]


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. :)
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15964
Share on other sites

[!--quoteo(post=353445:date=Mar 9 2006, 07:01 PM:name=Flinch)--][div class=\'quotetop\']QUOTE(Flinch @ Mar 9 2006, 07:01 PM) [snapback]353445[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
$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);
[/code]
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.
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15966
Share on other sites

[!--quoteo(post=353447:date=Mar 9 2006, 07:06 PM:name=7pm)--][div class=\'quotetop\']QUOTE(7pm @ Mar 9 2006, 07:06 PM) [snapback]353447[/snapback][/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.....

[code]
$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!";

[/code]

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! :)
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15971
Share on other sites

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>
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15972
Share on other sites

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:

[code]
$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!";
[/code]
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15986
Share on other sites

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?
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15988
Share on other sites

[!--quoteo(post=353471:date=Mar 9 2006, 08:07 PM:name=Flinch)--][div class=\'quotetop\']QUOTE(Flinch @ Mar 9 2006, 08:07 PM) [snapback]353471[/snapback][/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]

[b][!--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![/b]
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15992
Share on other sites

[!--quoteo(post=353474:date=Mar 9 2006, 08:12 PM:name=7pm)--][div class=\'quotetop\']QUOTE(7pm @ Mar 9 2006, 08:12 PM) [snapback]353474[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[b][!--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![/b]
[/quote]

No problem. Glad to help someone in need!
Link to comment
https://forums.phpfreaks.com/topic/4570-php-issue/#findComment-15995
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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