/    Sign up×
Community /Pin to ProfileBookmark

Comments & question.

Resolved.
Thanks DJsac. ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@DJsACNov 26.2004 — [code=php]
if(!isset($accepted))
{
echo "The form will be sent using the following information.<br>";
print("<form action='".$_SERVER[PHP_SELF]."'>n
<input type='text' name='NAME' disabled value='".$_POST['NAME']."'><br>n
etc etc...
<input type='hidden' name='unid' disabled value='".$id."'>n
<input type='submit' name='accepted' value='Accept Values'>n
<input type='submit' name='no' value='Cancel Registration'>n
</form>n
");
$mail = false;
}
if(isset($accepted))
{
$mail = true
}
if(isset($no))
{
//canceled registration code here
$mail = false
}


//change:
if($mail === true)
{
$fh = fopen("/home/me/count.txt","r");
$id = fread($fh, filesize("/home/me/count.txt"));
fclose($fh);

$id++;

$fh = fopen("/home/me/count.txt","w");
fwrite($fh, $id);
fclose($fh);

$to = "[email protected]";
$subject = 'Site [ID:' . $id .']';
$headers = "From: Website <[email protected]>rn";
$headers .= "Reply-To: " . $_POST['EMAIL'] . "rn";
$headers .= "X-Mailer: OurSite Mailerrn";
$headers .= "Abuse: [email][email protected][/email]rn";
$forward = 0;
$location = "http://www.domain.com/thanks.php";

$date = date ("l, F jS, Y");
$time = date ("h:i A");

$msg = "Below is the result of your feedback form. It was submitted on $date at $time with ID:$id.nn";
$msg .= "IP: ".$_SERVER['REMOTE_ADDR']."nn";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "n";
}
}

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

// reset the code.
unset($_SESSION['correctcode']);

if ($forward == 1) {
header ("Location:$location");
}
else {
include "/home/me/header.php";
echo "<p class="title">Thanks!</p>n<p>Blah blah blah .. your ID for this submission is: <strong>[ID:" . $id . "]</strong>.</p>n";
include "/home/me/footer.php";
}
}[/code]


Something like that should work nicely ?
Copy linkTweet thisAlerts:
@DanUKauthorNov 26.2004 — hiya. thank you for that, that's great!

where would the validation etc go though? ?

regards,
Copy linkTweet thisAlerts:
@DJsACNov 26.2004 — Use it like it was,

Validate, but instead of going on and emailing immediately, refresh the page with the form, have them click Accept or Cancel, and then go to the mail part ?


In the first form, add a hidden field with name='form1' value='herewego'

in the script:
[code=php]
if(!isset($_POST['form1'])
{
//echo the form or message saying they have to register via the form
}
if((isset($_POST['form1']) AND ($_POST['form1'] == "herewego"))
{
//Validate the registrant's info
//At the end of validation, put $msg into the session as $_SESSION['msg']
}
if((!isset($accepted)) AND (isset($_POST['form1']) AND ($_POST['form1'] == "herewego"))
{
echo "The form will be sent using the following information.<br>";
print("<form action='".$_SERVER[PHP_SELF]."'>n
<input type='text' name='NAME' disabled value='".$_POST['NAME']."'><br>n
etc etc...
<input type='hidden' name='form1' disabled value='herewego'>n
<input type='hidden' name='unid' disabled value='".$id."'>n
<input type='submit' name='accepted' value='Accept Values'>n
<input type='submit' name='no' value='Cancel Registration'>n
</form>n
");
$mail = false;
}
if((isset($accepted)) AND (isset($_POST['form1']) AND ($_POST['form1'] == "herewego"))
{
$mail = true
}
if((isset($no)) AND (isset($_POST['form1']) AND ($_POST['form1'] == "herewego"))
{
//canceled registration code here
$mail = false
}
if($mail === true)
{
$msg = $_SESSION['msg'];
$fh = fopen("/home/me/count.txt","r");
$id = fread($fh, filesize("/home/me/count.txt"));
fclose($fh);

$id++;

$fh = fopen("/home/me/count.txt","w");
fwrite($fh, $id);
fclose($fh);

$to = "[email protected]";
$subject = 'Site [ID:' . $id .']';
$headers = "From: Website <[email protected]>rn";
$headers .= "Reply-To: " . $_POST['EMAIL'] . "rn";
$headers .= "X-Mailer: OurSite Mailerrn";
$headers .= "Abuse: [email][email protected][/email]rn";
$forward = 0;
$location = "http://www.domain.com/thanks.php";

$date = date ("l, F jS, Y");
$time = date ("h:i A");

$msg = "Below is the result of your feedback form. It was submitted on $date at $time with ID:$id.nn";
$msg .= "IP: ".$_SERVER['REMOTE_ADDR']."nn";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "n";
}
}

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

// reset the code.
unset($_SESSION['correctcode']);

if ($forward == 1) {
header ("Location:$location");
}
else {
include "/home/me/header.php";
echo "<p class="title">Thanks!</p>n<p>Blah blah blah .. your ID for this submission is: <strong>[ID:" . $id . "]</strong>.</p>n";
include "/home/me/footer.php";
}
}[/code]
×

Success!

Help @DanUK 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.11,
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,
)...