Forums

PHP

This topic is locked

PHP Form + Totals + MySQL + Email

Posted 31 Mar 2008 02:23:41
1
has voted
31 Mar 2008 02:23:41 Tom Simmons posted:
Phew.

Hi all. I have put together a seminar registration form which puts everything into a MySQL database for the client to go in and charge credit cards etc. (all under SSL) after the fact - this isn't a storefront type setup with a payment gateway.

Now (surprise) they have come back and requested that the total amount to be charged appear to the client to "approve" and that an email is sent out to the registrant.

I am only familiar with doing this in ASP (form then confirm page then write to database and email) but their platform won't support ASP and I am not a PHP pro. I know enough to usually keep myself out of trouble.

I did this all in DW CS3 with the standard tools.

Does anyone have any suggestions on whether this can be done with hidden fields + code like ASP, extensions, tutorials, code etc. that they could point me to in this regard for these features? Is there hope? <img src=../images/dmxzone/forum/icon_smile_shy.gif border=0 align=middle>

Thanks in advance.

Tom

Replies

Replied 31 Mar 2008 12:21:47
31 Mar 2008 12:21:47 Alan C replied:
Hi
sounds like clients, they don't know what they want, but they know what they don't want when they see the finished job

<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>

Check out session variables, php has a built-in mechanism for securely holding information and passing it between pages, basically you start a 'session' and the server tracks you automatically, then you can add variables etc and pick them up off other pages.


Your emails can be sent using the php mail function, something like this would do it . . . this function should return true or false depending on whether or not the email was actually sent. The things in all caps are defined elsewhere in a file that gets 'included'

<pre id=code><font face=courier size=2 id=code>
function tellAdmin($to,$message){
$now_date=date('r');

$from = "From: ".EMAIL_ERROR_REPORT." &lt;".EMAIL_ERROR."&gt;";
$subject = "domain name.com Site - internal error reporting";
$body = "An internal error has occured in the system,\n\n"
.$message." \n\n"
."Message generated: ".$now_date;

return mail($to,$subject,$body,$from);
}
</font id=code></pre id=code>


Hope that helps
Replied 31 Mar 2008 16:52:09
31 Mar 2008 16:52:09 Tom Simmons replied:
Good thought.

I've used the sessions with a login / password system that pulled up a record. I'll just have to figure out how to add the form items <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

I appreciate the email info too. Thanks for taking the time to help me out!

Tom
Replied 07 Apr 2008 23:57:47
07 Apr 2008 23:57:47 John Silva replied:
i dont know the right programing way, but i usualy do it with a hiden field, wich picks the sessiona variables like this
&lt;input type="hidden" name="id_usr" id="id_usr" value="&lt;?php echo ($row_rsresume_rsm['id_usr']); ?&gt;" /&gt;
wich the id_usr is generated by a recorset using the session login variable.
All the best from portugal
Replied 08 Apr 2008 22:58:00
08 Apr 2008 22:58:00 Tom Simmons replied:
Thanks for the code! I appreciate the response.

Reply to this topic