/    Sign up×
Community /Pin to ProfileBookmark

More than one actions per form?

Hey

How do I add more than action per Form?

I have a registration form which sends data to a database on submit. I want it to send data to a mail aswell…how do I do that?

Regards
Dennis Ingham

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@GarySJul 12.2006 — You can only have one action statement for a form... but that action can point to a script that can do any number of things.

Here's a rough outline (treat as pseudo code... it's probably riddled with errors)

[code=html]

<?php

if(isset($_POST['submit']) ){

//validate

//Do other stuff
//e.g., Store in a database
//e.g., send an email

}
?>
<html>
<head>
</head>
<body>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">

<input type="submit" name="submit" value="Save">
</form>

</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@Dennis_InghamauthorJul 12.2006 — Thanks GaryS I'll try that!
Copy linkTweet thisAlerts:
@Dennis_InghamauthorJul 12.2006 — Hi again.

I can post the data to the database, but I can't figure out the mail - maybe it's because i'm using the wrong PHP script:

My codes looks like this:

[COLOR=DarkRed]<?PHP

if (isset($_POST['submit'])){

echo $editFormAction;



$to = '[email protected]';

$subject = 'Ny tilmelding';

$message ='Der er kommet en ny tilmelding';

$headers = 'MIME-Version: 1.0' . "rn";

$headers = 'Content-type: text/html; charset=iso-8859-1' . "rn";

$headers = 'To: Dennis <[email protected]>' . "rn";

$headers = 'From: Dennis Ingham <[email protected]>' . "rn";



mail($to, $subject, $message, $headers);

}

?>[/COLOR]


I'm a little newbie in PHP programming so...maybe I just picked up the wrong script.

Anyone who knows how to sent mail with PHP scripting?
Copy linkTweet thisAlerts:
@The_Little_GuyJul 12.2006 — I added . before the = sign. Try that.
[code=php]<?PHP
if (isset($_POST['submit'])){
echo $editFormAction;

$to = '[email protected]';
$subject = 'Ny tilmelding';
$message ='Der er kommet en ny tilmelding';
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
$headers .= 'To: Dennis <[email protected]>' . "rn";
$headers .= 'From: Dennis Ingham <[email protected]>' . "rn";

mail($to, $subject, $message, $headers);
}
?>[/code]
Copy linkTweet thisAlerts:
@bokehJul 12.2006 — [code=php]?>
<html>
<head>
</head>
<body>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">[/code]
[/QUOTE]
Using [I]$_SERVER['PHP_SELF'] [/I]in that context is insecure.
Copy linkTweet thisAlerts:
@GarySJul 12.2006 — Yes, you're quite right. Laziness struck me again.
Copy linkTweet thisAlerts:
@ShearsJul 13.2006 — Why is it insecure?
Copy linkTweet thisAlerts:
@bokehJul 13.2006 — Why is it insecure?[/QUOTE]Becuase [B][I]$_SERVER['PHP_SELF'][/I][/B] can be manipulated by the user.
Copy linkTweet thisAlerts:
@Dennis_InghamauthorJul 13.2006 — Thank you all...now it's working ?

To bokeh: how can I change $_SERVER['PHP_SELF'] into a secure statement, but with the same function?
Copy linkTweet thisAlerts:
@bokehJul 13.2006 — [code=php]htmlentities($_SERVER['PHP_SELF'])[/code]
Copy linkTweet thisAlerts:
@Dennis_InghamauthorJul 13.2006 — OK thanks 'll try that
×

Success!

Help @Dennis_Ingham spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...