mattennant Posted April 25, 2006 Share Posted April 25, 2006 helloi posted this in dreamweaver help, but was advised to post here instead, hope that's okon the homepage of the site i am building the user can subscribe to an email newsletter. It's a simple text box which on submitting adds the email to a database. What i am trying to achieve is th add a thankyou for subscribing to the textbox after the user has submitted their details. here's the code for the form[code]<form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td><input type="text" name="email" value="<?php if ($thankyou == "yes") { echo "thankyou"; }else{ } ?>" size="23"></td> </tr> <tr valign="baseline"> <td><input type="submit" value="submit"></td> </tr> </table> <input type="hidden" name="thankyou" value="thankyou"> <input type="hidden" name="MM_insert" value="form1">[/code]i now as far as i see it need to add[code]$thankyou = "yes";[/code]somewhere in the insert record code that dreamweaver has spewed out[code]<?php require_once('Connections/balance.php'); ?><?phpfunction GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {$thankyou = "yes"; $insertSQL = sprintf("INSERT INTO balance_newsletter (email, thankyou) VALUES (%s, %s)", GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['thankyou'], "text")); mysql_select_db($database_balance, $balance); $Result1 = mysql_query($insertSQL, $balance) or die(mysql_error()); $insertGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); }[/code]but wherei have tried just about everywhere to no availany ideas mat Quote Link to comment https://forums.phpfreaks.com/topic/8364-adding-a-variable-as-a-form-is-submitted/ Share on other sites More sharing options...
mattennant Posted May 2, 2006 Author Share Posted May 2, 2006 bump Quote Link to comment https://forums.phpfreaks.com/topic/8364-adding-a-variable-as-a-form-is-submitted/#findComment-32565 Share on other sites More sharing options...
wildteen88 Posted May 2, 2006 Share Posted May 2, 2006 You already have setup a hidden form field in your form called thankyou and the form is getting suvmitted to itself, so you can just do the following instead:[code]<input type="text" name="email" value="<?php if (isset($_POST['thankyou'])) { echo "thankyou"; } ?>" size="23">[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8364-adding-a-variable-as-a-form-is-submitted/#findComment-32662 Share on other sites More sharing options...
mattennant Posted May 3, 2006 Author Share Posted May 3, 2006 that makes sense, but for some reason it's still not working, i can't think of any reason why it shouldn't though. Thanks for having a look. Quote Link to comment https://forums.phpfreaks.com/topic/8364-adding-a-variable-as-a-form-is-submitted/#findComment-33154 Share on other sites More sharing options...
cefalufr Posted May 4, 2006 Share Posted May 4, 2006 I tried using Dreamweaver to handle PHP Database Coding for about 2 days. Dont. Its horrible. Its better off learning how to do it. Quote Link to comment https://forums.phpfreaks.com/topic/8364-adding-a-variable-as-a-form-is-submitted/#findComment-33339 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.