Any PHP geeks here?

fisicx

Moderator
Sep 12, 2006
47,039
9
15,548
Aldershot
www.aerin.co.uk
I'm experimenting with hidden fields to solve a simple solution but it doesn't work (probalby because I'm pant's at programming).

A form has a hidden field that contains the email subject:

<input type="hidden" name="subject" value="some text string">

This gets sent to a php file that processes the form. I'm using:

$subject = $_POST['subject'];


then after validation the message gets sent:

mail("[email protected]", $subject , $message, "From: [email protected]");

$subject isn't getting picked up and processed. When I get the email the subject line is blank

What's missing? All the tutorials say the variables should get passed just like from a normal input but mine isn't.
 

fisicx

Moderator
Sep 12, 2006
47,039
9
15,548
Aldershot
www.aerin.co.uk
Cancel everything - found the pesky problem, a missing semi colon!
 
Upvote 0

fisicx

Moderator
Sep 12, 2006
47,039
9
15,548
Aldershot
www.aerin.co.uk
Indeed they are!

Got a new puzzle now that again should be fairly simple but I can't do it.

Suppost I want to do a calcuation on the page. The one I'm fiddling with is to add a 2% surcharge on card payments. I'd like a wee caculator thingy the where I can enter the cost of the item and click 'calculate' and the new value appears on the screen.

I can do the calculation but the results appears on a new page:

$cost = post['cost'];
echo $cost*1.02;

I'm sort of getting my head round the $_SERVER['PHP_SELF'] thing but not that comfortable yet.

Any suggestion would be most appreciated
 
Upvote 0

fisicx

Moderator
Sep 12, 2006
47,039
9
15,548
Aldershot
www.aerin.co.uk
Ta muchly, didn't relalise the php_self thing was such a problem. I do however utilise a lot of validation which strips out anything iffy and there are two levels of bot blocking.

Joseph, I've had a look at JS and agree it looks much simpler. Only trouble is my JS skills are even worse than my PHP!
 
Last edited:
Upvote 0

fisicx

Moderator
Sep 12, 2006
47,039
9
15,548
Aldershot
www.aerin.co.uk
Thank you. I'll be at the bar in a couple of hours with a pint for you.
 
Upvote 0

Latest Articles