PHP - Using A Php Variable As A Html Form Name
Similar TutorialsHi I struggle with something i'm trying to achieve. Maybe this is not the correct approach, i don't know. My goal is to attribute a string of a field of the form to a string variable in order to use this string variable in order to "auto fill" the field of the form previously completed. This is to do what is apparently called a sticky form... First the program attributes the string of a field of the form to a string variable : $EmitterFirstName = $_POST["EmitterFirstName"]; Then in the html form there is a field called "EmitterFirstName", and i want to use the string variable $EmitterFirstName in order to auto fill the field with the string previously typed by the user : <input type="text" name="EmitterFirstName" value="<?php $EmitterFirstName ?>"/> But it doesn't work as expected. Do you have any idea why or maybe an advice on how to code such a thing ? Thanks, Can someone please tell me what I am doing wrong here? For some reason, the variable doess not seem to be getting passed to the "action" php script this input is in my html form (action=post)... <input type="hidden" name="httpreferer" value="<?php echo $_SERVER['HTTP_REFERER'] ?>" /> this is in the action script... $httpreferer=$_POST['httpreferer']; echo $httpreferer; I have a php string variable that is created by php code within an html form ($answer). I need to pass this string variable along with all the html form input data to another php script specified with the form "action" (post method). All the html form input data is coming thru fine but not the variable ($answer). How do I do this? Here is the php code for importing html form data at the script called in the form action: $languages = $_POST['languages']; $answergiven = $_POST['answergiven']; $problemanswer = $_POST['$answer']; 'languages' and 'answergiven' are form inputs and come thru fine. '$answer' does not get passed to the second script. How do I do this? Here is the php code within the first html form <?php // OPEN DATABASE $username="servics3_sample"; $password="sample"; $database="servics3_sample"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); // GENERATE RANDOM PROBLEM NUMBER $probnum = (rand ( 1 , 9 )); echo $probnum; // RETRIEVE ANTI-SPAM PROBLEM $query="SELECT * FROM liasantispam WHERE `problem number` LIKE '%$probnum%' "; $result=mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); $firstnum=mysql_result($result,0,"first number"); $operator=mysql_result($result,0,"operator"); $secondnum=mysql_result($result,0,"second number"); $answer=mysql_result($result,0,"answer"); echo $firstnum," ",$operator," ",$secondnum," = "; mysql_close(); ?> I have a form that users input user name, password, and email... all writes to csv fine. My problem is I need to concatenate a a string with a variable and some html code will preserving the html when written to the csv.. I need the csv to be this username,password,email,user,category,text with http://sub.domain..com/splash/,something,something here's what i have Code: [Select] <?php if($_POST['formSubmit'] == "Submit") $varUserName = $_POST['username']; $varPW = $_POST['PW']; $varEmail = $_POST['email']; { $fs = fopen("testcsv.csv","a"); fputcsv($fs, array($varUserName,$varPW,$varEmail,"user","title",",category","some text '<a href="http://$varUserName.url.com/splash/>site.com</a>',)); fclose($fs); exit; } ?> and of course I'm getting Parse error: syntax error, unexpected T_STRING, expecting ')' on line 9 Hi all, I have an html form that sends formdata to a php script called example.php with the POST method. example.php then has the following structu Code: [Select] <?php if(isset($_POST['var1'])) {$var1 = $_POST['var1'];} else {$var1 = 'English';} if(isset($_POST['var2'])) {$var2 = $_POST['var2'];} else {$var2 = 'French';} print" <html> <body> <form> <select id='select1'> <option>var1</option> <option>var2</option> <option>etc...</option> </select> <input type='text' id='input1'> ETC. ETC. </form> </body> </html> "; ?> So example.php has an embedded html form. How do I specify that some elements of the form should take their values from the variables retrieved at the start of the script via the POST command? For example, I want select1 to have 'var1' pre-selected and I want input1 to display var2. var1 & var2 get sent through to example.php fine, I just don't know how to get the embedded html form to use them. Please help! Thanks a lot. Quote <?php $var = "http://www.google.com" ; ?> <iframe id="I1" name="I1" src= http://www.google.com style="width: 1186px; height: 1346px; float: middle"> Your browser does not support inline frames or is currently configured not to display inline frames. </iframe></div> Instead of the bold parts, I want the frame to show what $var links to, but as I have closed ?PHP, it will not return the link. Any help on how to make it go to $var? How can I add html tags in php as a variable? For example, for some reason my code gives me a header error if I use html before the php tags. I just need to add the style in there. I was wondering how I could add a style of any html tag within php as a variable?? Like I was thinking like <?php $style = "<style> div.error { border: 1px dashed #660000; background: #fee; color: #660000; } </style>"; echo $style; ?> But that would probably just print out the code... how can I make it so it wont print out on screen and I can actually use the style? Sorry for the noob question... im kind of an intermeddiate php programmer but the noobs questions still seem to never go away! Hi all. I have this code. <?php $ext = ' <form action="/members/clubs/view-activity.php" method="post" name="venuefrm"> <button type="submit" id="close" class="link"><span>View Activity</span></button> <input name="activity" type="hidden" value="<?php echo $activites['activityID']; ?>" /> </form>'; ?> The code falls down at the value="<?php echo $activites['activityID']; ?>" part. Can someone please show me how I break into php to write this part properly as I dont understand an it is obviously wrong. Thanks Danny <?php function money($amount,$separator=true,$simple=false){ return (true===$separator? (false===$simple? number_format($amount,2,'.',','): str_replace('.00','',money($amount)) ): (false===$simple? number_format($amount,2,'.',''): str_replace('.00','',money($amount,false)) ) ); } $income = 5000000000; $daily = money($income*24,true,true); $weekly = money(($income*24)*7,true,true); $monthly = money((($income*24)*7)*30,true,true); ?> </center> <center> <table border="1"> <tr> <td>Daily</td> <td><?php echo $daily ?></td> </tr> <tr> <td>Weekly</td> <td><?php echo $weekly ?></td> </tr> <tr> <td>Monthly</td> <td><?php echo $monthly ?></td> </tr> </table> </form> </center> What am I doing wrong? Im fairly new to this I have a contact form in html with captcha image.The Captcha image is randomnly created using a php file and stored in a session variable. But when i check whether the session (captcha variable) and the use entered captcha value i dont get answer. posting my code below Code: [Select] contact.php(html's action page) if(isset($_POST['csubmit'])) { $name=$_POST['cname']; $lname=$_POST['last_name']; $email=$_POST['cemail']; $tele=$_POST['telephone']; $comments=$_POST['comments']; $date_posted=date('Y:m:d H:i:s');$status='Inactive'; $security_code=$_POST['security_code']; //echo $security_code; //echo"<br>". $_SESSION['security_code']; //$_SESSION['security_code'] = $code; //echo $_SESSION['security_code']; //if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { //if(!(empty($_SESSION['security_code'] ) ||strcmp($_SESSION['security_code'], $_POST['security_code']) != 0)) //if(empty($_SESSION['security_code'] ) || $_POST['security_code']) != 0) //if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { $sql="insert into contact_us(first_name,last_name,email,contact_number,comments,status,date_posted) values('$name','$lname','$email','$tele','$comments','$status','$date_posted')"; $res=mysql_query($sql); $mail_to_user ="qq@qq.com"; $mail_subject_user="Comments "; $mail_body_user='<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"> Sir,<br> Please see the comments </td> </tr> <tr> <td width="20%"> </td> <td width="14%"><strong>First Name</strong></td> <td width="66%">'.$_POST[cname].'</td> </tr> <tr> <td> </td> <td><strong>Last Name</strong></td> <td>'.$_POST[last_name].'</td> </tr> <tr> <td> </td> <td><strong>Email</strong></td> <td>'.$_POST[cemail].'</td> </tr> <tr> <td> </td> <td><strong>Telephone Number</strong></td> <td>'.$_POST[telephone].'</td> </tr> <tr> <td> </td> <td><strong>Comments</strong></td> <td>'.$_POST[comments].'</td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table>'; $headers_user="MIME-Verson:1.0\n"; $headers_user.="Content-Type: text/html;charset=iso-8859-1\n"; $headers_user.="Content-Transfer-Encoding: 8bit\n"; $headers_user.="From: bb@qq.com\n"; $headers_user .="Bcc: aa@gg.com\r\n"; mail($mail_to_user,$mail_subject_user,$mail_body_user,$headers_user); echo "<script language='javascript'>alert('Message has been sent to the Administrator.');</script>"; //=================email to user $mail_to_user1 = $_POST['cemail']; $mail_subject_user1 = "Thanks for contacting with us "; $mail_body_user1 ='<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> Sir,<br> We are very much glad to hear from you. We will contact you soon. <br/><br/> Thanks, <br/>Cusrtomer Care</td> <td> </td> <td> </td> </tr> </table>'; $headers_user1="MIME-Verson:1.0\n"; $headers_user1.="Content-Type: text/html;charset=iso-8859-1\n"; $headers_user1.="Content-Transfer-Encoding: 8bit\n"; $headers_user1.="From: aa@qq.com "; mail($mail_to_user1,$mail_subject_user1,$mail_body_user1,$headers_user1); //header('Location:contact_us.html'); echo "<script> self.location='contact_us.html';</script>"; //} /*else{ //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() //unset($_SESSION['security_code']); echo"<script language='javascript'>alert('The security code you entered is not correct');</script>"; echo "<script> self.location='contact_us.html';</script>"; //header('Location:contact_us.html'); // $errors .= "\n The captcha code does not match!"; }*/ /*else{ ?> <script language="javascript"> alert("The security code you entered is not correct"); history.go(-1); </script> <?php } */ } unset($_SESSION['security_code']); Code: [Select] html form=========contact_us.html <form name='contact_form' id='contact_form' method="post" action="contact.php"> <table width="518" height="341" align="center" border="0" style=" vertical-align:top"> <tbody><tr><td width="202" height="28" valign="middle" align="left"> <label for="first_name"><span class="style26 style20">First Name *</span></label> </td> <td width="14" align="center" valign="middle">:</td> <td width="448" valign="top" > <div class="con" ><input type="text" size="30" maxlength="50" name="cname" id="cname" class="contact_text"> </div> </td> </tr> <tr> <td valign='middle'> <label for="last_name"><span class="style26 style20">Last Name *</span></label> </td> <td align="center" valign="middle">:</td> <td valign="top"> <div class="con" > <input type="text" size="30" maxlength="50" name="last_name" id="last_name" class="contact_text"></div> </td> </tr> <tr> <td valign="middle"> <label for="email"><span class="style26 style20">Email Address *</span></label> </td> <td align="center" valign="middle">:</td> <td valign="top"><div class="con" ><input type="text" size="30" maxlength="50" name="cemail" id="cemail" class="contact_text"/></div></td> </tr> <tr> <td valign="middle"> <label for="telephone"><span class="style26 style20">Telephone Number</span></label> </td> <td align="center" valign="middle">:</td> <td valign="top"> <div class="con" > <input type="text" size="30" maxlength="80" name="telephone" id="telephone" class="contact_text" > </div> </td> </tr> <tr> <td height="123" valign="middle"> <label for="comments"><span class="style26 style20">Comments *</span></label> </td> <td align="center" valign="middle">:</td> <td valign="middle"> <div class="cmn_ct"><textarea rows="6" cols="25" maxlength="1000" name="comments" id="comments" onfocus=" this.value = this.value.replace(/\s+/g,'');" onblur="checkLength(this.value,0,100);" class="cmn_text"></textarea></div> </td> </tr> <tr><td><label for="security code"><span class="style26 style20">Security Code *</span></label></td><td align="center" valign="middle"></td><td><img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" alt="security_code" height="22" id="security_code" name='security_code' class='secuimage'/><br /> <div class="se_code"><input id="security_code" name="security_code" type="text" class="secuInput" /></div> <center></td> <tr> <td height="26" colspan="3" style="text-align: center;"> <table width=69% align="right"> <tr><td align='left'> <input type="submit" value="Submit" name="csubmit" onclick="return verify();"> </td></tr></table> </td> </tr></table></form></p> Code: [Select] CaptchaSecurityImages.php <?php class CaptchaSecurityImages { var $font = 'monofont.ttf'; function generateCode($characters) { /* list all possible characters, similar looking characters and vowels have been removed */ $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; } function CaptchaSecurityImages($width='120',$height='40',$characters='6') { $code = $this->generateCode($characters); /* font size will be 75% of the image height */ $font_size = $height * 0.75; $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream'); /* set the colours */ $background_color = imagecolorallocate($image, 255, 255, 255); $text_color = imagecolorallocate($image, 20, 40, 100); $noise_color = imagecolorallocate($image, 100, 120, 180); /* generate random dots in background */ for( $i=0; $i<($width*$height)/3; $i++ ) { imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); } /* generate random lines in background */ for( $i=0; $i<($width*$height)/150; $i++ ) { imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); } /* create textbox and add text */ $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function'); $x = ($width - $textbox[4])/2; $y = ($height - $textbox[5])/2; imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function'); /* output captcha image to browser */ header('Content-Type: image/jpeg'); imagejpeg($image); imagedestroy($image); $_SESSION['security_code'] = $code; } } $width = isset($_GET['width']) ? $_GET['width'] : '120'; $height = isset($_GET['height']) ? $_GET['height'] : '40'; $characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6'; $captcha = new CaptchaSecurityImages($width,$height,$characters); ?> I just want to know how will i pass a session variable frm php to html thru js and from there to the php page where action of the html page occurs? apparently I am doing this wrong. I want my string results from a form that searches DB content to appear within HTML table, tr, td tags. I get the results fine, but the HTML part isn't appearing. How should I be doing this? <?php $string = ''; $result = mysql_query($sql); /// This is the execution if (mysql_num_rows($result) > 0){ while($row = mysql_fetch_object($result)){ echo "<table>"; echo "<tr>"; $string .= "<td>".$row->last_name."</td> "; $string .= "<td>".$row->first_name."</td>"; $string .= "<td>".$row->employee_id."</td>"; $string .= "<td>".$row->title."</b>"; $string .= "<td>".$row->territory."</td>"; $string .= "<td>".$row->district."</td>"; $string .= "<td>".$row->Phase1A_Score."</td>"; $string .= "<td>".$row->Phase1B_Score."</td>"; $string .= "<td>".$row->Phase1_Average."</td>"; $string .= "<td>".$row->Phase1A_HS_Exam."</td>"; $string .= "<td>".$row->Phase1A_HS_Exam_RT."</td>"; $string .= "<td>".$row->Phase1B_HS_Exam."</td>"; $string .= "<td>".$row->Phase1B_HS_Exam_RT."</td>"; $string .= "<td>".$row->Class_Date."</td>"; $string .= "<td>".$row->Awards."</td>"; $string .= "<br/>\n"; echo "</tr>"; echo "</table>"; } }else{ $string = "No matches found!"; } echo $string; ?> Hello I want to be able to change the class depending on if a variable is 1 or 0. <html> <p class="note-general"> This is the general </p> <p class="note-warning"> And this is the warning </p> </html> I want the variable $adult (that can be 1 or 0) to set if the class should be a note-general or note-warning. Thank you for support I'm redoing my login script using functions and a basic switch function checking against a $_GET variable (hope you guys know what I'm talking about). What I want to do is create two functions: 1 that displays the login form and 1 that processes the information The form tag would look like this: <form action=\"<?php $_SERVER['PHP_SELF']?>?action=process\" method=\"post\"> </form> Here's my switch statement: Code: [Select] <?php //**************************************** //****************Action****************** //**************************************** switch ($_GET["action"]) { default: case "index": if (!$_SESSION["member"]) { if (!$timeout) { display_form(); } else { echo $timeout_error; } } else { echo "You are already logged in."; } break; case "process": if (!$_SESSION["member"]) { if (!$timeout) { process_form(); } else { echo $timeout_error; } } else { echo "You are already logged in."; } break; } ?> This runs as soon as "login.php" loads. It'll automatically run the commands under case "default" and "index". It'll first check to see if the member's logged in. If not, it'll then check to see if "$timeout" is true ($timeout becomes true if the member has attempted to login 5 times and failed). If not, it'll display the login form, by running "display_form()". Once the form has been filled and submitted, the commands under case "process" will be performed. Again it will first check to see if the member's logged in. If not, it'll check to see if "$timeout" is true. If not, it'll start validating the forms. For the validation, I've created a variable called "$errors_found", and scripted one if statement checking to see if the email and password exist. If so, the variables "$rm_field_un" and "$rm_field_pw" become true, as well as "$errors_found". So, back to submission of the form... If "$errors_found" is true, display the form (when the form is displayed, there will be an if statement within that says "<?php if ($rm_field_un) { echo "Username is wrong."; } ?>", which will be displayed right underneath the username field and label. Same with the password elements). If "$errors_found" is not true, go ahead and register the member. Now, here's where I need help, because I'm really confused as to how to accomplish this. The "display_form()" function will contain a single variable called "$login_form". It will contain a value of the HTML constructed login form, and the function will return the variable. Remember how I stated in the third paragraph up that I will have <php> statements within the form which would display errors if necessary? Well, how do I put those if statements within the HTML, which is contained within the variable? If that last question confuses you, allow me to present you with an instance: Code: [Select] <?php function display_form() { $login_form = " <form name=\"login_form\" method=\"post\" action=\"<?php $_SERVER['PHP_SELF']?>?action=process\"> Username: <input type=\"text\"> <?php if ($rm_field_un) { echo "Username is wrong"; } ?> "; return $login_form; } ?> See what I mean? This code confuses me ALOT. I'm not sure if the <php> tags are needed as it is already contained within existing ones, or what. Can somebody please help me out? Any and all help is much appreciated. =D I know this is 'old stuff', but I am new to this and very frustrated- I am trying to pass a variable to a new url via an html onclick event, and failing. I have found several posts about it but the code posted in those posts does not work when I try it. I have struggled mightly with this. Here is my code: first an echo of two versions of the onclick statement, and two versions of the actual button code. The echos from the two versions appear identical, but the first button with no variable works while the second using a variable results in no action. Can anyone point me in the direction of a solution? I suspect there is some simple principal I am missing relating to parsing strings. <?php echo "window.location.href='ManageTitles.php?dog=2'"; echo "\n" ; echo "window.location.href='ManageTitles.php?dog={$row_rsDogsowned['idDogInfo']}'"; ?> <form methd="POST" Name="form3" action="<?php echo $editFormAction; ?>"> <input type="button" value="works" onclick="window.location.href='ManageTitles.php?dog=2'" /> <input type=button onclick="window.location.href='ManageTitles.php?dog={$row_rsDogsowned['idDogInfo']}'" value="fails" /> </form Usually it would be something like:
$("#lblpasswordmessage").html("Password is too short");But how do you do it using a variable? For example say the variable is called 'pwm'; $("#pwm").html("Password is too short"); $("pwm").html("Password is too short"); $(pwm).html("Password is too short");Thanks Hey guys. This is my code: <?php session_start(); if ($_SESSION['adminlogin'] == 1){ //Run } else { header('Location: Log-In.php'); exit; } ?> <!DOCTYPE HTML> <html lang="en-GB"> <head> <meta charset="utf-8"> <!--Search Engine Meta Tags--> <meta name="author" content="Worldwide Lighthouses"> <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel"> <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships"> <!--Stylesheets/Javascript--> <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)"> <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)"> <!--Mobile Browser Support--> <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <!--IE Support--> <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]--> <meta name="application-name" content="Worldwide Lighthouses"> <meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> <meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> <meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> <meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> <meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> <meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico"> <title>Mailing List Administration | Worldwide Lighthouses</title> </head> <body> <header> <h1 id="WWLH">Worldwide Lighthouses</h1> <form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box"> <input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off"> <input type="submit" value="Search"> <input type="hidden" name="search" value="1"> </form> </header> <nav> <ul id="Nav"> <li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li> <li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li> <li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li> <li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li> <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li> <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li> <li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li> </ul> </nav> <?php if ($_SESSION['adminlogin']==1) { echo '<div id="logout"> <div style="float:left; width:30%; text-align:left;!important"> <a href="Log-In-Accept-Deny.php">Back to Admin Home</a> </div> <div style="float:right; width:70%;"> <a href="Logout.php">Log Out of Admin</a> <p style="font-size:10px;">Always Sign Out when Finished!</p> </div></div>';} ?> <article> <?php $title = $_POST['title']; $introparagraph = $_POST['introparagraph']; $update1title = $_POST['update1title']; $update2title = $_POST['update2title']; $update3title = $_POST['update3title']; $update1caption = $_POST['update1caption']; $update2caption = $_POST['update2caption']; $update3caption = $_POST['update3caption']; $update1link = $_POST['update1link']; $update2link = $_POST['update2link']; $update3link = $_POST['update3link']; $maincontenttitle = $_POST['maincontenttitle']; $article = $_POST['article']; $articlelink = $_POST['articlelink']; ################################################################# #####################IMAGE UPLOAD SCRIPT######################### ################################################################# // Where the mainimage file is going to be placed $target_path_mainimage = "Newsletter-Images/Main-Images/"; // Wheere the update images will be places $target_path_updateimage1 = "Newsletter-Images/Update-Images/1/"; $target_path_updateimage2 = "Newsletter-Images/Update-Images/2/"; $target_path_updateimage3 = "Newsletter-Images/Update-Images/3/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ //Main $target_path_mainimage = $target_path_mainimage . basename( $_FILES['mainimage']['name']); //Update Images $target_path_updateimage1 = $target_path_updateimage1 . basename( $_FILES['update1']['name']); $target_path_updateimage2 = $target_path_updateimage2 . basename( $_FILES['update2']['name']); $target_path_updateimage3 = $target_path_updateimage3 . basename( $_FILES['update3']['name']); //Move the main image file to its location if(move_uploaded_file($_FILES['mainimage']['tmp_name'], $target_path_mainimage)) { } else{ echo "There was an error uploading the main image file, please try again!"; } //Move the update images to their location if(move_uploaded_file($_FILES['update1']['tmp_name'], $target_path_updateimage1)) { } else{ echo "There was an error uploading the 1st update image file, please try again!"; } if(move_uploaded_file($_FILES['update2']['tmp_name'], $target_path_updateimage2)) { } else{ echo "There was an error uploading the 2nd update image file, please try again!"; } if(move_uploaded_file($_FILES['update3']['tmp_name'], $target_path_updateimage3)) { } else{ echo "There was an error uploading the 3rd update image file, please try again!"; } ############################################################################## ######################### END IMAGE UPLOAD SCRIPT ############################ ############################################################################## $mainimageurl = "http://www.worldwidelighthouses.com/Newsletter/Admin/Newsletter-Images/Main-Images/".basename( $_FILES['mainimage']['name']); $update1imageurl = "http://www.worldwidelighthouses.com/Newsletter/Admin/Newsletter-Images/Update-Images/1/".basename( $_FILES['update1']['name']); $update2imageurl = "http://www.worldwidelighthouses.com/Newsletter/Admin/Newsletter-Images/Update-Images/2/".basename( $_FILES['update2']['name']); $update3imageurl = "http://www.worldwidelighthouses.com/Newsletter/Admin/Newsletter-Images/Update-Images/3/".basename( $_FILES['update3']['name']); $emailcontent = ' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>'.$title.'</title> </head> <body style="margin: 0; padding: 0;"> <table width="100%" cellpadding="0" cellspacing="0" bgcolor="#333333"><tr><td> <table cellspacing="15" id="main" align="center" width="600" cellpadding="0" bgcolor="ffffff" style="margin-top: 10px; border: 1px solid #cfcece;"> <tr> <td> <table id="header" cellpadding="10" cellspacing="0" align="center" bgcolor="#000000"> <tr> <td width="570" bgcolor="#356A5C"><a href="http://www.worldwidelighthouses.com" style="color: #FFF; text-decoration: none;"><h1 style="font-size: 24px; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; margin: 0; color: #ffffff; padding: 0;">Worldwide Lighthouses</h1></a><h2 style="font-size: 24px; font-family: Arial, Helvetica, sans-serif; margin: 0; color: #ffffff !important; padding: 0;">'.$title.'</h2></td> </tr> <tr> <td width="570" align="right" bgcolor="#154A3C"><p style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #ffffff; margin: 0; padding: 0;">'.date("F Y").'</p></td> </tr> </table><!-- header --> </td> </tr><!-- header --> <tr> <td></td> </tr> <tr> <td> <table id="content-1" cellpadding="0" cellspacing="0" align="center"> </table> <img src="'.$mainimageurl.'" height="190" alt="'.$title.'" width="570" style="display: block;" /><!-- content 1 --> </td> </tr><!-- content 1 --> <tr> <td> <table id="content-2" cellpadding="0" cellspacing="0" align="center"> <tr> <td width="570"><p style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode',".' sans-serif; color: #444444; margin: 0; padding: 0;">'.$introparagraph.'</p></td> </tr> </table><!-- content-2 --> </td> </tr><!-- content-2 --> <tr> <td> <table id="content-3" cellpadding="0" cellspacing="0" align="center"> <tr> <td valign="top" width="170" bgcolor="d0d0d0" style="padding: 5px;"> <a href="'.$update1link.'" style="color: #FFF; text-decoration: none;"><img src="'.$update1imageurl.'" alt="'.$update1title.'" style="display: block;" /></a> </td> <td width="15"></td> <td valign="top" width="170" bgcolor="d0d0d0" style="padding: 5px;"> <a href="'.$update2link.'" style="color: #FFF; text-decoration: none;"><img src="'.$update2imageurl.'" alt="'.$update2title.'" style="display: block;" /></a> </td> <td width="15"></td> <td valign="top" width="170" bgcolor="d0d0d0" style="padding: 5px;"> <a href="'.$update3link.'" style="color: #FFF; text-decoration: none;"><img src="'.$update3imageurl.'" alt="'.$update3title.'" style="display: block;" /></a> </td> </tr> </table><!-- content-3 --> </td> </tr><!-- content-3 --> <tr> <td> <table id="content-4" cellpadding="0" cellspacing="0" align="center"> <tr> <td width="180" valign="top"> <a href="'.$update1link.'" style="color: #FFF; text-decoration: none;"><h5 style="font-size: 18px; margin: 0 0 0.8em; font-family: Arial, Helvetica, sans-serif; color: #444444;">'.$update1title.'</h5></a> <a href="'.$update1link.'" style="color: #FFF; text-decoration: none;"><p style="font-size: 12px; line-height: 1.5; font-family:'." 'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;">'.$update1caption.'</p></a> </td> <td width="15"></td> <td width="180" valign="top"> <a href="'.$update2link.'" style="color: #FFF; text-decoration: none;"><h5 style="font-size: 18px; margin: 0 0 0.8em; font-family: Arial, Helvetica, sans-serif; color: #444444;">'.$update2title.'</h5></a> <a href="'.$update2link.'" style="color: #FFF; text-decoration: none;"><p style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;">'.$update2caption.'</p></a> </td> <td width="15"></td> <td width="180" valign="top"> <a href="'.$update3link.'" style="color: #FFF; text-decoration: none;"><h5 style="font-size: 18px; margin: 0 0 0.8em; font-family: Arial, Helvetica, sans-serif; color: #444444;">'.$update3title.'</h5></a> <a href="'.$update3link.'" style="color: #FFF; text-decoration: none;"><p style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;">'.$update3caption.'</p></a> </td> </tr> </table><!-- content-4 --> </td> </tr><!-- content-4 --> </tr><!-- content-5 --> <td> <tr bgcolor="#FFFFFF" align="center"> <a href="'.$articlelink.'" style="color: #FFF; text-decoration: none;"><td height="30"><h5 style="font-size: 18px; margin: 0 0 0.8em; font-family: Arial, Helvetica, sans-serif; color: #444444 !important; text-align:left;">'.$maincontenttitle.'</h5></a></td> </tr> <tr> <td> <table id="content-6" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF"> <p align="left" style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;">'.$article.'</p> <p align="center" style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;"><a href="http://www.worldwidelighthouses.com" style="text-decoration: none; color: #4A72AF;">Visit the website now!</a></p> </table> </td> </tr> </table><!-- main --> <table id="bottom-message" cellpadding="20" cellspacing="0" width="600" align="center"> <tr> <td align="center"> <p style="font-size: 12px; line-height: 1.5; font-family: Arial, Helvetica, sans-serif; color: #444444; margin: 0; padding: 0;">You are receiving this email because you signed up for updates</p> <p style="font-size: 12px; line-height: 1.5; font-family: Arial, Helvetica, sans-serif; color: #444444; margin: 0; padding: 0;"><a href="mailto:dantonybrown@hotmail.co.uk?subject=Unsubscribe%20Me&body=Please%20unsubscribe%20me%20from%20your%20mailing%20list" style="text-decoration: none; color: #4A72AF;">Unsubscribe instantly</a> </td> </tr> </table><!-- top message --> </td></tr></table><!-- wrapper --> </body> </html> '; echo '<div class="Textbox"><h2>Email Preview:</h2>'; echo '<p>If you are happy with the below preview (note: Make sure you check all links work and spelling is correct before sending) then click te button below</p>'; ?> <form action="Send-Email.php" method="post"> <input type="hidden" value="<?php $emailcontent?>" name="emailcontent"> <input type="submit" value="Send Email to Entire Contact List"> </form> </div> <?php echo $emailcontent;?> </article> <footer> <ul> <li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li> <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li> <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li> <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li> <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li> <li><a href="#Top">Back to top</a></li> </ul> <br> <br> &#169; Worldwide Lighthouses <?php echo date("Y"); ?> </footer> </body> Essentially what im trying to do is create and display a preview of an automatically generated email (which works) then i want the email (all of whoms code is contained in $emailcontent to be posted to the next page where it will actually send. However this does not seem to work. any advice? Thanks. Danny <head> <script language="javascript" type="text/javascript" src="datetimepicker.js"> </script> </head> <form action="main.php?id=test.php" method="post"> <p>Start Date: <input name="start" id="start" type="text" size="10"> <a href="javascript:NewCal('start','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> End Date: <input name="end" id="end" type="text" size="10"> <a href="javascript:NewCal('end','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> <input name="submit" type="submit" value="Look Up"> </form> <?php if(isset($_POST['submit'])) { $start = $_POST['start']; $end = $_POST['end']; $sql = "SELECT * FROM `corps` WHERE `notedate` BETWEEN '$start' AND '$end'"; $results = mysql_query($sql) OR DIE(mysql_error()); $numrow = mysql_num_rows($results) ; $i = 0; While ($i < $numrow) $shownotes = mysql_result($results,$i,'notes'); echo $shownotes."<br>"; { Echo "Records found ".$i."<br>"; $i++; } } The $start, and $end don't seem to be getting any values Hi, I have a weather app, coded which creates weather based on a set zip code. I want to create a form which when the user fills out their local code and clicks the send button that will change the zip code variable. Currently it is set up like this $zip = '90210'; //change to your zipcode need help with getting started with this. Thanks! Hi , how I can save something into form? I mean , insert something in variable and than insert it into value in the form so when i send the form the value will be send too. I also want that it will be can not change. for example : <input name="email" value="a@s.d"/> but this example can be change if you insert something else. thanks , Mor. I am stuck on trying to get the form to repopulate after a failed validation. The real form involves REST calls and such but I trimmed the code back to this issue. I think I need to declare the variables differently. I also tried to use the variables in the PHP script to refill the form with the original form entries. I have tried numerous ways of getting the variables to repopulate but could never get it to work consistently (such as declaring global variables. Here is the form code: Code: [Select] <div> <a name="error_field"></a> <?php if($_GET['error']): ?> <div style="padding:10px;border:1px solid;color:#C70C0C;"><?php echo $_GET['error'] ?></div> <?php endif; ?> <div> <form method="post" action="process2.php"> <fieldset name="Group1"> <legend>Account Registration</legend> <div id="field"><label id="Firstname">First Name:</label></div> <div id="input"><input name="Firstname" id="Firstname" type="text" value="<?php $_POST['Firstname']?>"/></div> <div id="field"><label id="Lastname">Last Name:</label></div> <div id="input"><input name="Lastname" id="Lastname" type="text" value="<?php $_POST['Lastname']?>"/></div> <div id="field"><label id="Username">E-Mail Username):</label></div> <div id="input"><input name="Username" type="text" value="<?= $_POST['Username']?>"/></div> <div id="field"><label id="Password">Password:</label></div> <div id="input"><input name="Password" type="password" /></div> <div class="center" style="margin-top:15px;margin-bottom:15px"> <input name="Submitx" type="submit" value="submit" /> <input name="Reset1" type="reset" value="reset" /> </div> </fieldset></form> </div> </div> and here is the PHP which I have on a different page Code: [Select] <?php $new_user_username = check_input($_POST['Username'], "Enter your e-mail"); $new_user_password = check_input($_POST['Password'], "Enter your password"); $new_user_first_name = check_input($_POST['Firstname'], "Enter your first name"); $new_user_last_name = check_input($_POST['Lastname'], "Enter your last name"); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $new_user_username)) { show_error("E-mail address not valid"); } else{ header('Location: TY.php'); } function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { header('Location: tp1.php?error=' . $myError); exit(); } ?> Thanks in advance for any help. |