...

View Full Version : show resulting output on another page and send url link to email



Razzy
07-13-2012, 11:16 AM
hey people, i am trying to create a simple form, and would like the user to input some details on a form, when the user clicks the submit button, it should load another page showing the input details.

also is there any way of sending the url link of the webpage to an email address?

the form is shown below:




<fieldset id="personal" >
<table align="center">
<tr>
<td style="font-weight:bold"> 1. First Name: </td> <td> <input type="text" name="first_name" /></td>
</tr>

<tr>
<br/>
<td style="font-weight:bold"> 2. Last Name: </td> <td> <input type="text" name="last_name_" /></td>
</tr>

<tr>
<td style="font-weight:bold"> 3. Firstline Address: </td> <td><input type="text" name="address"/> </td>
</tr>
<tr>
<td style="font-weight:bold"> 4. Post Code: </td> <td><input type="text" name="postcode"/> </td>
</tr>
<tr>
<td style="font-weight:bold"> 5. Telephone No: </td> <td><input type="text" name="tel_no"/> </td>
</tr>
<tr>
<td style="font-weight:bold"> 6. Email Address: </td> <td><input type="text" name="email"/> </td>
</tr>
</table>
<br/>

<table align="center">
<tr>
<td style="font-weight:bold">
7. Are you a Company or an individual? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>
</tr>
</table>

<table align="center" width="220px">
<tr>
<td> <input type="radio" name="group1" value="Company" />

Company</td>
</tr>
<tr>


<td><input type="radio" name="group1" value="Individual" />
Individual</td>
</tr>
</table>

<br/>

<table align="center">
<tr>
<td style="font-weight:bold">
7. Delivery or Pick-up from shop? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>
</table>

<table align="center" width="220px">
<tr>
<td align="left"><input type="radio" name="group2" value="Delivery"/>

Delivery</td>

</tr>
<tr>
<td>
<input type="radio" name="group2" value="Pick-up"/>

Pick-up</td>
</tr>
</table>

</td>
</tr>
</table>
</fieldset>



would really appreciate it if someone could help

thank you

mlseim
07-13-2012, 02:37 PM
So as it stands now, you only have the form you show in post #1?

Do you have a line that looks like ...
<form action="blahblah" method="post">

There needs to be a form action. That will be a PHP script
that processes the form and does whatever you want with the form data.

If you don't have a form action, and are not sure what I'm talking about,
you might want to use Google: PHP contact form script tutorial

=============

But back to the original question ... what URL link are you talking about?


url link of the webpage

I'm not sure what that means.

Razzy
07-13-2012, 03:49 PM
sorry i forgot to include the form tags....the coding below is for testing purposes but very similar to the one i posted first:




<form method="post" action="test2.php">>

<table>
<tr>
<td>
&bull; lamb burger<input type="hidden" id="valueB0" value="2.99"/>
<br/>
Quantity:<input type="text" id="qtyB0" name="qtyB0" size="2" value=""/>


&bull; chicken burger<input type="hidden" id="valueB1" value="4.20"/>
<br/>
Quantity:<input type="text" id="qtyB1" name="qtyB1" size="2" value=""/>


&bull; beef burger<input type="hidden" id="valueB2" value="4.20"/>
<br/>
Quantity:<input type="text" id="qtyB2" name="qtyB2" size="2" value=""/>
<br/>
<input type="button" onclick="calculateTwo();" value="Total"/>
<br/>
<span id="resultTwo"></span><br /><br />
</td>
</tr>
</table>

</form>



so basically i wanted the inputted values to be outputted in a tabular format in test2.php, and at the same time to send an email consisting the url of test2.php......so that both, (1) the user will see the results in a tabular format as soon as they click the submit button, and (2) and the company will also see the results via the url sent to the email address.

i hope u understand it this time :)

thank you very much for replying to the post

mlseim
07-14-2012, 02:16 AM
Does the user enter a URL?

I don't see how you aquire a URL.

Or ... are you telling me that the form shows up an many different websites?

Maybe your definition of a "URL" is not the same as mine?

jdswebservice
07-14-2012, 02:59 AM
If you are trying to have the form submit, THEN have the data entered displayed on page 2 PLUS emailed to an email address, thats pretty easy. If this is what you want let me know and i'll post code for ya!

J-

Razzy
07-14-2012, 06:49 PM
lol sorry mlseim, basically i wanted the link to the second page sent to an email address so that the company can view the submitted data too :)....

and yes jdswebservice, thats exactly what i want, however instead of the entered data displayed on the email address, i jus wanted the link of the SECOND page on the email address, so that member of staff within the company to which the website belongs to can view the entered data too by clicking the lnk :)

thank you very much

mlseim
07-14-2012, 07:37 PM
So, we can just post a plain contact page email script, but there's a lot more
that needs to be addressed ... which makes it hard for us to post a script.

What if they enter something wrong, or don't enter a particular box?
The form will need to have "validation", and tell them what's wrong either
on the 2nd page, or stay on the form and tell them.

What if a spammer decides to submit your form 1000 times using a spamming script?
The form will need some sort of captcha code or "is the user a human"?
Can ANYONE submit the form without any idea of who they are?

What if the user types it all out and submits it successfully, and then, oops, I put
the wrong address in there! Oh no ... how do I fix that? The user has to do the
form again and resubmit. But now, there are two emails sent. What if the recipient
only sees the first email (with the wrong address)?

What if the person submits the form and decides to add more items to their order?
They send another form? ... but the recipient gets two emails and may or may not
figure out if the person is adding to the previous order, or creating a new order.
This will be really confusing to the recipient?

Will the person who sent the form get some sort of confirmation showing the info
that they sent, and that the recipient has seen it? How will the person who sent
the form know that it was recieved?

See what I mean?
You have a lot more things to consider and decisions to make.
This just isn't a "send a form" script.

=========

Maybe each user needs to create a free account (register online).
Then, after confirming their email, they can log-in and fill-out any
orders that they wish. There are NO emails sent.
The recipient is the person (admin or owner) that accesses a webpage
showing ALL pending orders from anyone who has submitted an order.

Any changes to an order by the customer or client is updated
immediately in the database ... the owner sees that right away.
No more need to enter name and email ... because the user has logged-in.
That information has already been entered when they registered.



.

Razzy
07-14-2012, 07:52 PM
hey mlseim, yes this will all be done, i have only just started it, all i am just worried about at this point in time is if its possible to send the weblink of the SECOND page which will contain the filled in data, to an email address

jdswebservice
07-14-2012, 09:34 PM
Well, you COULD use the get method in your form(s), however this will be VERY unsecure. My suggestion is to do this. create the form, have it submit to page.2php. page2.php will then post that form to a database, and send a link to the email address provided with the ID of the entry in the database. then you create page3.php?id=x to read, view, and display the information to the people you want.

so page2.php emails the link in the form of,

http://website.com/page3.php?id=x

that'll then be the simple way of doing it, and most secure in my opinion. :D

Len Whistler
07-14-2012, 09:40 PM
hey mlseim, yes this will all be done, i have only just started it, all i am just worried about at this point in time is if its possible to send the weblink of the SECOND page which will contain the filled in data, to an email address

I would change the name of test2.php to something more descriptive. For the info to display on test2.php you need use the GET method to query the database. So the URL looks something like test2.php?client=27865. 27865 is the row ID that contains all the client info.


Do you have the database setup?
I recommend you study the php GET method and how it gets info from databases.

Razzy
07-14-2012, 10:23 PM
hey guys, no there is no database on this, basically i am creating an order form within the website of a meatshop, so basically a customer makes an order (they do not need to register), which involves inputting data on textboxes etc, and then it displays the results on another page, but i wanted some form of link of the other page on an email add....im not sure whether it is possible without having to create a database for it?

Len Whistler
07-14-2012, 10:31 PM
hey guys, no there is no database on this, basically i am creating an order form within the website of a meatshop, so basically a customer makes an order (they do not need to register), which involves inputting data on textboxes etc, and then it displays the results on another page, but i wanted some form of link of the other page on an email add....im not sure whether it is possible without having to create a database for it?

You need some sort of database to store and retrieve the info, and I recommend MySQL, I don't think you can do what you want without a database. MySQL is very easy top learn.

stevenmw
07-14-2012, 10:51 PM
Razzy, may I ask if there is there a specific reason you're wanting to have a page with the users' submitted info on it?


If you are trying to have the form submit, THEN have the data entered displayed on page 2 PLUS emailed to an email address, thats pretty easy. If this is what you want let me know and i'll post code for ya!

J-

I agree that this is a very easy method, and wouldn't even require a DB.

But if there is a specific reason you're needing a page complete with a url then the other posts are spot on. You need a DB in order to assign an id to each post in order to give you a unique url for each submission.

mlseim
07-15-2012, 07:33 AM
You are thinking that when a form is submitted to "test2.php" the script will
display the form data on the user's browser and then send an email to the business
with a link back to that page with the form data. So when the form data is displayed
on the user's browser, that is a "webpage", that can be linked back to from an email.

Is that what you think happens?

==============

If it is, you're not seeing it correctly.

When the form is filled out and they click submit, the form variables are
sent to the script called "test2.php". That script can send the form values
to any email and then display "Thank You for your order". You can send the
data to the business email AND the user's email (as a confirmation). There
is no "webpage" created, and there is no link back to any webpage.
There is no webpage period.

We're saying that the form variables should be written into a database and their
are no emails at all. The business continually checks the database for new orders.
The users can also check the database to see the status of their order(s).

Razzy
07-15-2012, 08:10 PM
hey stevenmw, when the user inputs the data, the second page shows shows the inputted data in a tabular format, the reason why i want a second page is for the user to see what he/she has inputted. and the link sent to the email is for the company to view the orders.

so for instance if the url for the second page is: www.blahblah.com/test2.php

then that url should be sent to the email.

just like how form inputs are sent to email addresses with the use of php, im wondering if its possible to send that url to email without the database? if not then i gues im gna have to create a database

stevenmw
07-15-2012, 08:48 PM
Well, you COULD use the get method in your form(s), however this will be VERY unsecure. My suggestion is to do this. create the form, have it submit to page.2php. page2.php will then post that form to a database, and send a link to the email address provided with the ID of the entry in the database. then you create page3.php?id=x to read, view, and display the information to the people you want.

so page2.php emails the link in the form of,

http://website.com/page3.php?id=x

that'll then be the simple way of doing it, and most secure in my opinion. :D

This is going the be the easiest way, Razzy.

mlseim
07-15-2012, 11:19 PM
I'm still wondering why the email cannot contain the same data that
the user sees on the 2nd page. Why does it have to be a link and not
just give them the form information right inside the email text?

That's the part that is so strange to me.

stevenmw
07-15-2012, 11:25 PM
I think he is wanting some kind of physical invoice that can be accessible in the future for whatever reason.

Am I close?

DrDOS
07-16-2012, 12:14 AM
This is the first time I looked at this thread and I can see right away the bar on this could be raised much higher. If you don't really need to send to an email, but the customer needs some kind of receipt how about this scenario?

Customer fills out form, submits it, if it is all filled out correctly it goes to another page where there is a download button and he can download his receipt.
If it isn't filled out correctly it goes back to the form page where the form is automatically filled in again but a request is made to correct the omissions/errors.

If you like this scenario let me know, and I'll help you write it. Writing a download php is one of the easiest things you can do, and I know how to refill a form by using js and php, likewise easy. And redirect, that's easy too. The only thing at all complicated is evaluating the form fields, either before or after submission.

Razzy
07-16-2012, 01:49 PM
yes stevenmw ur almost close, however the main reason i wanted the link, is so that the staff within the company can look at the order placed by the particular user(customer) on the company email, and then they can make that order for the customer.

mlseim i know i could just show the form info on email text, however i wanted the staff within the company to view the orders placed by the customers on a tabular format.

DrDOS thnx but basically the input details will not go to the customers email add, it will be to the company's email add so that the staff could see what the customer has ordered

mlseim
07-17-2012, 12:15 AM
You send them an HTML email instead of plain text.
It can be formatted with CSS or anything you want.
Whether you use <table> or <div> ... doesn't matter.
In fact, you could include images as well.

What happens to the HTML page (file) you've created after the company views it?
Do you just keep adding them to a directory, or delete them ???
How will that be managed?

And using FPDF, technically the whole order could be made into a PDF file and attached to an email.
That's more advanced though, but just a thought.

Razzy
07-18-2012, 03:41 PM
hey mlseim thats is a brilliant thought, i could possibly make the order into a pdf file and send it as attachment, will it still require me to create a database? can it be done without creating database, thank you

mlseim
07-18-2012, 04:11 PM
It can be done without a database, but you'll need to learn how to do FPDF.

http://www.fpdf.org/

There is a link called "scripts" which shows actual working examples.
Find an example sort of similar to what you're doing and study it.
I see there's an example of an invoice, but it appears to have way
more stuff on it than you will need. All of the examples have a link
at the bottom to "view it" and see how it looks.

There's one example called "HTML" where it shows how to convert
some plain HTML into a PDF. Script example, listing, and a demo.

You can save your PDF files in a directory, giving them some sort of
order number for a filename. eg. ID_12441234221.pdf
The number could be a timestamp (UNIX time): time();

The email would link back to that if you didn't want to attach it.
So, it could be done with or without an email attachment.
You can also email it to the person who submitted the form.

FPDF will be your learning curve now.


.

Razzy
07-18-2012, 06:32 PM
thank you mlseim, i think this would be the best way to do it :)

Len Whistler
07-18-2012, 11:49 PM
Below is a fully working script I put together that might be useful, it outputs the form to a html file. Each html file has a unique URL because of the random number generator, which acts as a order id.

Save it as orders.php and you can test it. It of course would need lots of mods to suite your needs.


orders.php

<?php

if (isset($_POST['submit_post'])) {
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];

//write to html file, and give unique url
$order_number = rand(1000, 9999);
$html_page = "orders-$order_number.html";
$fh = fopen($html_page, 'w') or die("can't open file");

fwrite($fh, "<html>\n<body>\n");
fwrite($fh, "<h1>THANKS FOR YOUR ORDER #$order_number </h1>\n");
fwrite($fh, "First Name: $first_name<br>\n");
fwrite($fh, "Last Name: $last_name<br>\n");
fwrite($fh, "</body>\n</html>");

fclose($fh);

//redirect to new html file
header("Location: orders-$order_number.html");
}
?>
<html>
<body>
<center>
<form method="post" action="orders.php">
<table>
<tr><td>First Name:</td><td><input type="text" size="20" maxlength="20" name="first_name" value=""></td></tr>
<tr><td>Last Name:</td><td><input type="text" size="20" maxlength="20" name="last_name" value=""></td></tr>
</table>
<br><br><input type="submit" value="Submit Data" name="submit_post">
</form>
</center>
</body>
</html>


This is the output the script above produces, which is viewed as a webpage.

orders-1842.html

<html>
<body>
<h1>THANKS FOR YOUR ORDER #1842 </h1>
First Name: Leonard<br>
Last Name: Whistler<br>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum