webmaster1 Posted December 6, 2008 Share Posted December 6, 2008 Hi All, I have a basic form that returns a message when correctly submitted. <?php if ($message_success) echo ''.$message_success.''; ?> It currently appears beneath my form. I need the form to dissapear and only show this message. Any ideas? Link to comment https://forums.phpfreaks.com/topic/135801-solved-basic-exit-form-but-not-page-after-submit-need-form-to-dissapear/ Share on other sites More sharing options...
webmaster1 Posted December 6, 2008 Author Share Posted December 6, 2008 I've tried using exit(); While this makes the form dissapear it also makes the entire page dissapear. Link to comment https://forums.phpfreaks.com/topic/135801-solved-basic-exit-form-but-not-page-after-submit-need-form-to-dissapear/#findComment-707702 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 <?php if($message_success) echo $message_success; else { //put form in here } ?> Link to comment https://forums.phpfreaks.com/topic/135801-solved-basic-exit-form-but-not-page-after-submit-need-form-to-dissapear/#findComment-707716 Share on other sites More sharing options...
webmaster1 Posted December 6, 2008 Author Share Posted December 6, 2008 I'm getting a parse error. Do I need to close off the php blocks surrounding the html of the form? <?php if (isset($_POST['submit'])) { if (strlen($_POST['name']) > 0) {$name=TRUE;} else {$name=FALSE; $message_name=" *Please complete this field!"; } if (strlen($_POST['contact']) > 0) {$contact=TRUE;} else {$contact=FALSE; $message_contact=" *Please complete this field!";} if ($name && $contact) { include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to establish a connection to the relevant database."); $name = mysql_real_escape_string($_POST['name']); $contact = mysql_real_escape_string($_POST['contact']); $message = mysql_real_escape_string($_POST['message']); $ipaddress = getenv('REMOTE_ADDR'); $query = "INSERT INTO eventcontact VALUES ('','$name','$contact','$message','$ipaddress',NOW())"; mysql_query($query); $message_success="Your message has been sent. We will be in touch shortly. Thank you for your interest.</br></br> <a href='index.php'>Send another message</a>"; //exit(); } } ?> <!------------------------------------------------------------------> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Joyce Promotions</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="jprevised.css" rel="stylesheet" type="text/css"> </head> <body TOPMARGIN="0" LEFTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td rowspan="4" width="166" height="1200" class="leftbar"></td> <td width="631" height="67" class="nav"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="631" height="67" id="nav" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="flash/nav.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#000000" /> <embed src="flash/nav.swf" quality="high" bgcolor="#000000" width="631" height="67" name="nav" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </td> </tr> <tr> <td width="631" height="309" class="flash"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="631" height="309" id="flash" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="flash/flash.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#000000" /> <embed src="flash/flash.swf" quality="high" bgcolor="#000000" width="631" height="309" name="flash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </td> </tr> <tr> <td width="631" height="520" class="blurb"></td> </tr> <tr> <td width="631" height="304" class="form" valign="top"> <!---------------------------------------------------------------------> <!--BEGIN FORM AND SET IT TO PROCESS SELF AND HANDLE MULTIPART/FORM-DATA--> <a name="mainform"></a> <?php /////////////////////////////////////////////// if($message_success) {echo $message_success}; else { //put form in here <form action="<?php echo $_SERVER['PHP_SELF']; ?>#mainform" method="post" enctype="multipart/form-data"> <fieldset> <ol> <li> <label for="name">Contacts Name:</label> <input type="text" name="name" id="name" class="textbox" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>"/> <?php if ($message_name) echo ''.$message_name.''; ?> </br> </li> <li> <label for="contact">Email / Phone:</label> <input type="text" name="contact" id="contact" class="textbox" value="<?php if (isset($_POST['contact'])) echo $_POST['contact']; ?>"/> <?php if ($message_contact) echo ''.$message_contact.''; ?> </br> </li> <li> <label for="message">Your Message:</label> <textarea rows="3" cols="70" class="textarea" name="message" id="message"><?php if (isset($_POST['message'])) echo stripslashes($_POST['message']); ?></textarea> </li> <li> <input type="submit" name="submit" id="submit" class="submit" value="Submit Message" onmouseover="this.className='submitnhov'" onmouseout="this.className='submit'"> </li> </ol> </fieldset> </form> } ?> <!---------------------------------------------------------------------------------> </td> </tr> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/135801-solved-basic-exit-form-but-not-page-after-submit-need-form-to-dissapear/#findComment-707733 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 yes you do ?> before the html starts and <?php to close the if statement Link to comment https://forums.phpfreaks.com/topic/135801-solved-basic-exit-form-but-not-page-after-submit-need-form-to-dissapear/#findComment-707741 Share on other sites More sharing options...
webmaster1 Posted December 6, 2008 Author Share Posted December 6, 2008 I need to get some sleep... zzz! Works great; thanks. Link to comment https://forums.phpfreaks.com/topic/135801-solved-basic-exit-form-but-not-page-after-submit-need-form-to-dissapear/#findComment-707750 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.