|
 |
|
 |
02-21-2007, 03:57 PM
|
#1 (permalink)
|
|
Recruit
Join Date: Feb 2007
Posts: 20
|
Confirmatin Page & Email ->CONT'D from HTML Forum
Hello all. This is a continuation from my post in the HTML forum. Thanks to redhead I'm almost at the finish line of my web page code problems.
OK redhead, now that I have my order page (page with numerous tables containing rows of checkboxes):
#1) Once the user clicks SUBMIT on the order page, I need to get whichever results the user checked and display them in a list in a confirmation page in a separate window with the calculated price. The price is calculated by the number of items checked/wanted. If they want less than 10 items its $5 per item, between 10 and 20 items its $4 per item, etc. etc. Also on the confirmation page will be the desired payment option (check, money order, Paypal, etc.) and delivery options (email or mail). If they choose regular mail then an additional $5.25 will be added to the price. And lastly a text box for them to input their email address.
#2) Now the user clicks the CONFIRM button and the form results plus the confirmation page data is sent to me in an email. The only thing I didn't like in my research on this whole problem is that email spider bots roam the internet scavenging email addresses from the source code of websites and use them for reasons that mostly end in malicious conduct. Is there still a way to get the results via email and beat these email scavenger bots at their game?!
Thanks In Advance,
JM
|
|
|
02-21-2007, 08:38 PM
|
#2 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
|
So what have you got so far for part 1? For part 2, you don't have to put the email address in the visible output in the page. Remember the browser only sees the output of the PHP script. Web Spiders can't see your PHP source code.
__________________
Stop intellectual property from infringing on me
|
|
|
02-22-2007, 01:33 PM
|
#4 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
Sorry, just got home after an 18 hour day, I'll get back to you when I have the time, but now I need my beauty sleep 
|
|
|
02-22-2007, 02:36 PM
|
#5 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 651
|
__________________

UT: Ultra-kill... God like!
|
|
|
02-22-2007, 03:58 PM
|
#6 (permalink)
|
|
Recruit
Join Date: Feb 2007
Posts: 20
|
redhead... hey np get your beauty rest and when you are rested and have time you can get back to this post
DJMaze... thanks for the link. I will look into that site and see what part of the code I can use.
-JM
|
|
|
02-24-2007, 04:12 AM
|
#7 (permalink)
|
|
Recruit
Join Date: Feb 2007
Posts: 20
|
OK I have been doing some studying and saw the basics of what I need to display a pop-up window confirmation page of the form results for the potential customer. I guess I have to input the boldfaced html code below in my Order page to pass the form results to the php Confirmation page (I included the full example html form code to understand the variables "quantity" and "item")
Code:
<html><body>
<h4>Tizag Art Supply Order Form</h4>
<form action="process.php" method="post">
<select name="item">
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
Quantity: <input name="quantity" type="text" />
<input type="submit" />
</form>
</body></html>
Then I have to create a php Confirmation page with variables set to the "posted" html form values. Here is the basic code I found
Code:
<html><body>
<?php
$quantity = $_POST['quantity'];
$item = $_POST['item'];
echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Tizag Art Supplies!";
?>
</body></html
So in my php Confirmation page I have to set a variable for every input checkbox I have in my html form? So if it is checked in the html Order form then it will be printed in the php Confirmation page?
Thanks,
JM
|
|
|
02-24-2007, 05:39 AM
|
#8 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
If yo name the checkbox something like:
Code:
<input type="checkbox" name="mycheckbox[]" value="apples">
<input type="checkbox" name="mycheckbox[]" value="orranges">
You'll be able to access it through PHP as an array like:
PHP Code:
$checked = $_POST['mycheckbox'];
foreach($checked as $check)
// do stuff with $check
However I havn't quite figured out, how that namingscheme would work out with your checkAll() javascript...
|
|
|
02-24-2007, 09:16 AM
|
#9 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
Just for fun, I've made a test page to illustrate how it could be done...
It is build on top of a database layout like
Code:
CREATE TABLE categories (
id INT(11) DEFAULT '0' NOT NULL auto_increment,
name CHAR(50) NOT NULL,
UNIQUE id (id),
PRIMARY KEY id (id)
);
CREATE TABLE items (
id INT(11) DEFAULT '0' NOT NULL auto_increment,
category INT(11) NOT NULL,
name CHAR(50) NOT NULL,
description BLOB,
UNIQUE id (id),
PRIMARY KEY id (id),
FOREIGN KEY (category) REFERENCES categories
);
Let me know if this is what you were looking for...
Last edited by redhead; 02-24-2007 at 09:57 AM.
|
|
|
02-24-2007, 01:26 PM
|
#10 (permalink)
|
|
Recruit
Join Date: Feb 2007
Posts: 20
|
Yea not too sound too simplistic but that test page is almost exactly what my needs are. The choices with the checkboxes and the allbox checkbox option on one page and then when SUBMIT is clicked a separate page with the results displayed as a confirmation.
The only thing I need to add to the confirmation page where it displays the results of the choices checked is 1) calculated price based on results 2) an input text for their email address 3) and a checkbox choice between delivery options of mail or email.
You mentioned databases. Does the Order page javascript need to be slightly changed or overhauled to accomadate a confirmation page that displays the checkboxed results?
-JM
|
|
|
02-24-2007, 11:59 PM
|
#11 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
Quote:
|
1) calculated price based on results
|
As you can see, my database layout dosn't include any price assignement to the item at hand, but that wouldn't be too complicated.
Quote:
|
2) an input text for their email address
|
That can be added very easily
Quote:
|
3) and a checkbox choice between delivery options of mail or email.
|
Again, this is very easy to add...
Quote:
|
Does the Order page javascript need to be slightly changed or overhauled to accomadate a confirmation page that displays the checkboxed results?
|
If you look at the page-source you'll see, I had to make some changes to the checkAll() function, but it wasn't that problematic.
When adding the calculation of prices, I think it would be more complete to just use the id of the item instead of name, as the value to the checkbox. This would require more work in the confirmation page, but it would provide a more secure solution towards false/positive occurencies.
The reason I made it, was to see if it was fairly easy to combine the javascript part from yours with the ease of dynamic PHP pages formed from some database gathered info, as it turned out, it wasn't that difficult.
Look at it, as a proof of concept.
Now the next step will be for you to make it, with guidence from me and others here, like DjMaze, sde, tekno, etc. As it is always best to learn along the way, instead of ripping some code, which you dont fully understand. Creating HTML pages like this, is alog the lines of thinking HTML in 3d 
|
|
|
02-25-2007, 01:37 PM
|
#12 (permalink)
|
|
Recruit
Join Date: Feb 2007
Posts: 20
|
Adding to the Confirmation page the calculated price, input textbox for email, and delivery checkbox as you said seems pretty easy due to my recent studies. Although I wouldn't trust myself yet calling it easy or not due to my inexperience also.
As for guiding me along the way to coding my needs instead of just script-ripping, I also agree and greatly appreciate, because in real life I am a teacher and relish every opportunity to learn something new. I tried to break down the mail script in the PHP link DJ sent me but to no avail.
For future reference, I personally have a small experience in coding and programming as I have taken classes in Pascal and FORTRAN in college. So I know the general layout and syntax of how program code works. I just need to know how to speak in that code language to write it correctly.
Before I forget, would it be easier to set the data associated to the checkboxes I have in the tables in the Order page to a small database? I was just thinking that it would be easier for the javascript to figure out which boxes to check when I click the allbox for each table and to display the calculated price in the confirmation page. -JM
|
|
|
02-27-2007, 05:25 AM
|
#13 (permalink)
|
|
Recruit
Join Date: Feb 2007
Posts: 20
|
OK doing a little research and studying of SQL database manipulation, I found some functions that could help in more ways than one.
Would it be possible to have the javascript pass the checked results on the Order page to SQL queries that display results and calculate price on the Confirmation page? Reason I ask is because I was seeing certain SQL commands and operators such as CREATE INDEX , SELECT, and COUNT(*). As I am understanding COUNT(*) would work as returning selected checkboxed rows to display results and count how many results which I could work into a formula to calculate the price.
I am just throwing options out that would make for a strong yet fast and easy result returning system; but also be easy to update in the future.
-JM
|
|
|
02-27-2007, 07:03 AM
|
#14 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
Quote:
|
Would it be possible to have the javascript pass the checked results on the Order page to SQL queries that display results and calculate price on the Confirmation page?
|
Every bit of info submitted from your checkboxes and teh like is beeing accessibel in the $_POST variable, the thing is, if you'd use a uniq description, like the ID tag, you would be able to do any form of operation directly from the results returned, that beeing calculate a price or extract further info about an item to display to the viewer.
When building the checkbox page, you'd fetch whatevver you have in your database and display it to the user, this is somethign like what my page is doing:
PHP Code:
/* select what we have in the database, and build the form for submitting */ $categories = @mysql_query("SELECT * FROM categories ORDER BY id", $DB_LINK); while($category = @mysql_fetch_array($categories)){ $item_count = 1; $body .= "<td valign='bottom'><font size='+2'><b>".$category['name']."</b></font> <input type='checkbox' name ='allbox".$category['id']."' onclick=\"checkAll('".$category['id']."');\" /> Check All <table border='0' cellspacing='0' cellpadding='0' width='100%' style='border: 1px solid rgb(12, 13, 119);'> <tr> "; $items = @mysql_query("SELECT * FROM items WHERE category=\"".$category['id']."\" ORDER BY id", $DB_LINK); while($item = @mysql_fetch_array($items)){ if(!(($item_count++) %2)) $body .= "</tr><tr><td valign='top'> "; /* only two items valigned within a category */ else $body .= "<td valign='top'>"; $body .= "<input type='checkbox' value='".$item['id']."' name='checkbox[".$category['id']."][]'><b>".$ite m['name']."</b><br /> ".$item['description']."</td> "; }
As you can see from this, the building of the HTML code from the mysql-queries and loops is like thinking of it in 3D.. Or thats how I usualy visualise it while writing the code.
So to keep it simple, heres how I would fetch the things, once submit has been pressed, if you were to use the id's as values in your checkboxes:
PHP Code:
if(isset($_POST['checkbox'])){ /* we were called through the 'submit' button * so we build the page accordingly */ $categories = @mysql_query("SELECT id FROM categories ORDER BY id", $DB_LINK); $checked = $_POST['checkbox']; while($category = @mysql_fetch_array($categories)){ foreach($checked[$category['id']] as $check){ $res = @mysql_query("SELECT * FROM items WHERE id='$check'", $DB_LINK); while($row = @mysql_fetch_array($res)){ /* do whatever with what is fetched, name, description, price, etc. */ } } } }
|
|
|
02-27-2007, 06:32 PM
|
#15 (permalink)
|
|
Recruit
Join Date: Feb 2007
Posts: 20
|
OK again thanks for taking the time out to work on some code chunks.
Two questions.
1) Is the first chunk of PHP code in the last reply to replace the javascript you helped me out with to check all in a certain table? I assume you are calling the "checkbox page" what I call my Order page. My Order page is the one that has all the checkboxes where the customer checks which product they want. So Order page --> Confirmation page --> Email Results
2) OK what you mean by "id" is assign something like a numeric value to each product that will also serve as the primary key in the database; and enter that numeric value into the value box in the checkbox properties?
EX:
ID PRODUCT
001 Ecology
enter 001 into the value box in the checkbox properties on the Order page.
That way when the checkbox is checked it will be passed to the Confirmation page which will make a query based on all checkboxes that are checked and return those values?
-JM
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 05:10 AM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|