PHP - Help With Cookie Redirect On Php Form Page.
First, I would like to say hi to everyone, I just registered, so I am new to the forums!
But at any rate, I have a question. I have a form that I have programmed in PHP and upon completion of the form, sends the inputed information to my clients e-mail (acts as a lead) and redirects the user to the main part of the website, where you can access all of the content. Now, I need a little assistance on how to make it so if the same user comes back to the site again, they won't always have to fill out the form and it will just forward them to the main page. Clarification: This is what I'm trying to figure out When you go to the url for the first time, the index page has the form on it that must be filled out before you can access the rest of the pages on the website (I have this set as a redirect in the php processing after you submit the form). What coding would I have to add to the html on the form page (index) and/or my php processor and/or the html on the page you are redirected to? My overall goal is for the user to only see the form page once, after they have submitted it the first time, the next time they visit the url, I want them automatically re-directed to the main part of the site since they already completed the form. For Example: (I have this part programmed and working already) The user goes to http://www.example.com for the first time and they see the page with the form on it. They fill it out and click "Submit" and are re-directed to http://www.example.com/page2.html, this redirect is handled with a header "location" command. (This is the part I need help with) At a future time the same user returns to http://www.example.com and since they have already filled out the form they are automatically re-directed to http://www.example.com/page2.html without having to hit the "Submit" button or really even see the form page. Thank you very much in advance, I appreciate your help! Similar Tutorials<?php require_once('upper.php'); $error_msg=''; if(!isset($_COOKIE['LoginIdCookie'])){ if(isset($_POST['submit'])) { require_once('database.php'); $LoginId=mysqli_real_escape_string($dbc,trim($_POST['LoginId'])); $Password=mysqli_real_escape_string($dbc,trim($_POST['Password'])); if((!empty($LoginId)) && (!empty($Password))){ $query="SELECT * FROM registration WHERE LoginId='$LoginId' AND Password=SHA('$Password') AND Flag='A'"; $result=mysqli_query($dbc,$query) or die('Not Connected'); if(mysqli_num_rows($result)==1) { $row=mysqli_fetch_array($result); setcookie('LoginIdCookie',$row['LoginId']); //$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index1.php'; header('Location: index1.php'); } else{ echo 'Enter right UserName/Password combination or You may not approved yet. '; echo '<a href="ForgetPassword.php">Can\'t access your account?"</a>'; }} else{ echo' Fill all fields'; } }} ?> <html> <title>Log In</title> <body> <?php if(empty($_COOKIE['LoginIdCookie'])) { echo $error_msg; ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ;?>" > <div class="LoginValidator"> <fieldset> <legend> Log In</legend><table><tr><td> <label for="username">User Name :</label><br/><br/></td> <td><input type="text" name="LoginId"><br/><br/></tr> <td><label for="password">Password :</label></td> <td><head> <div id="divMayus" style="visibility:hidden">Caps Lock is on.</div> <SCRIPT language=Javascript> function capLock(e){ kc = e.keyCode?e.keyCode:e.which; sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false); if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk)) document.getElementById('divMayus').style.visibility = 'visible'; else document.getElementById('divMayus').style.visibility = 'hidden'; } </SCRIPT> </HEAD> <input onkeypress='return capLock(event)' type="password" name="Password"><br/></td></tr></table> <input type="submit" name="submit" value="Login" class="Login_button"> </fieldset> </div> </form> <?php } else{ echo 'You are logged in as '.$_COOKIE['LoginIdCookie']; } require_once('lower.php'); mysqli_close($dbc); ?> HI friends.......... In above code when I enter wrong user name or password, it displays error msg properly but problem is that when i enter right user name and password instead to redirect to index1.php it displays LoginPage again.......... I think cookie is not created as well.......... I can't understand where is problem???????/ please help me.................... I am fairly new to PHP and am having an issue with getting my form to redirect to a thank you page upon sending the form email. I currently have it set to echo a thank you message but it needs to be changed to ensure that we can track all form fills better. I have tried the header method but it doesn't work correctly based on how the website is designed. It seems like there should be an easy way without redesigning too much. Are there any other ways to accomplish this? Please let me know what I need to do in order to get the redirect to work. Ive tried using header and form action and my page will not load into another page after submitting ! Any ideas?
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Task2 - App</title> <meta name="description" content="The Task2 App"> <meta name="author" content="SitePoint"> </head> <body> <h1>Task 2 - Web App</h1> <br><br> <div class ="submission"> <form action="" method="POST" name='submit'> <label>N:</label> <input type="text" name="number-entered" id="number"/> <input name="form" type="submit" value="Submit"/> <br><br> </form> </div> </body> </html> <?php $number = $_POST['number-entered']; $form_result = $_POST['form']; if(isset($form_result)) { if(($number < 5) || ($number > 25)) { echo 'Input out of range'; } else { $number = $_POST['number-entered']; foreach ( range(1, $number) as $i ) { $triangle_numbers[] = $i * ( $i + 1 ) / 2; } //make a file $contents = fopen('gs://a1-task22020.appspot.com/triangular_' .$number. ".txt", "w"); fwrite($contents,implode(',', $triangle_numbers)); //open the file $contents = fopen('gs://a1-task22020.appspot.com/' . $content, 'w'); //re-open the document if you put something in it fwrite($contents, $number); fclose($contents); } } ?>
I have two pages. one is insert_events.php and the other is veiw_events. In insert_events i have a form which have a submit button. I want when i click on the submit button, it redirects me to the view_events.php page showing the events. Any idea about this problem will be appreciated. Thanks Hi there,
Is it possible to redirect to another URL based on the cookie that has already loaded on the page?
For example,
If cookie = cookie_name then redirect to http://www.google.com
Thanks!
Hi people, I am a complete newbe to php but can some one please help us out a little with a bit of code? Basically i have a contact form, when the user submits the form it gets processed by my php page and the data sent of to my email address. The thing is I have wrote most of the code for this and i think it should work, however i want to add a bit of code that re-directs the user to a "thank you" page after they submit the form. I hope that makes sense, please check out the code below and please let me know what and where to put the re-direct code, please also let me know if the code i have written so far is correct. my code Code: [Select] <?php if(isset($_POST['submit'])) { $to = "me@my_email_address.com"; $subject = "Contact Form"; $name = $_POST['name']; $comp_name = $_POST['company_name']; $email = $_POST['email']; $phone = $_POST['contact_number']; $location = $_POST['location']; $message = $_POST['message']; $body = "From: $name\n E-Mail: $email\n Company Name: $comp_name\n Contact Number: $phone:\n Location: $location:\n Message:\n $message"; mail($to, $subject, $body); } ?> Cheers people, hope some one can help. Can anyone provide a snip of code that I could insert into the "coupon code" field on a formmail form which has the following effect: on submit form, user goes to the normal payment page (this is already implemented) if coupon code field is filled out with correct code, user is taken to alternate payment page on form submit. Either this or another approach which has the same result is OK. I am a novice coder working in a wysiwyg - I don't REALLY know php at all - I just need a snip I can insert and a clear instruction. Thanks so much for any help. Hi, I have a, let's call it, Main page, and it refreshes every 5 seconds to check the database... If it finds a result, it kills the refresh function and allows a DIV to call a page into itself via another function on the Main page, which refreshes every second, it's a timer count down clock... The problem is, that if the timer runs down to zero, I have it do a lot of things, but then I need it to either refresh the Main page, redirect the Main page, or close the Main page entirely... Does anyone know how I could perform either 3 of those actions from within the page that's inside of the DIV? I got a weird problem; I got a form whit 2 fields and a submit button; When i click the submit button a jquery ajax script create a cookie named form; My problem is the form isn't disappearing when i click the submit(javascript is set to reload location) button even when i try to delete the cookie from the browser; on index: Code: [Select] function addcomment($pass , $pst)//add comment and call form { $cpageid = $pass; $comment = new Comment; $comment->storeFormValues($pst); $comment->insertc(); require('comment.php'); } on the page where the form is called: Code: [Select] <div id="commentbox" class="container_24"> <?php if(!isset($_POST['form'])) { addcomment($result['article']->id,$_POST);//addcoment on the page whit the current id } ?> </div> Hello again everyone, I am new to PHP. This is the second part of a question: Question: In the program you created in question 4, allow your user the option of saving the information for the next time they visit. If they choose "yes", save information in a cookie. At the bottom of question5.php I added a checkbox to save the information. I then created an if statement on the processing page (question5display.php. I would appreciate some help, thanks guys. Here is the form ( called it question5.php): <html> <head> <title> Please Enter Your Text</title> </head> <body> <form method="post" action="question5display.php"> <p>Enter the text you want formatted please: <input type="text" name="textformat" maxlength="30" size="30" /> <table> <tr> <td><label for="font">Select Font:</label></td> <td><select id="font" name="font"> <option value="Verdana">Verdana</option> <option value="Arial">Arial</option> <option value="Times New Roman">Times New Roman</option> </select> </td> </tr> <tr> <td><label for ="size">Select Size:</label></td> <td><select id="size" name="size"> <option value="10px">10px</option> <option value="12px">12px</option> <option value="14px">14px</option> <option value="20px">20px</option> </select> </td> </tr> <tr> <td><label for="color">Select Color:</label></td> <td><select id="color" name="color"> <option value="green">Green</option> <option value="blue">Blue</option> <option value="red">Red</option> </select> </td> </tr> </table> <input type="checkbox" id="save_prefs" name="save_prefs" /> <label for="save_prefs">Save these preferences for the next time you log in.</label> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> Here is the page it goes to (called it question5display): <?php if (isset($_POST['save_prefs'])) { setcookie('font', $_POST['font'], time() + 60); setcookie('size', $_POST['size'], time() + 60); setcookie('color', $_POST['color'], time() + 60); $_COOKIE['font'] = $_SESSION['font']; $_COOKIE['size'] = $_SESSION['size']; $_COOKIE['color'] = $_SESSION['color']; } session_start(); $_SESSION['textformat'] = $_POST['textformat']; $_SESSION['font'] = $_POST['font']; $_SESSION['size'] = $_POST['size']; $_SESSION['color'] = $_POST['color']; ?> <html> <head> </head> <body> <p <?php echo ' style="font-family: ' . $_SESSION['font'] . '; '; echo 'font-size: ' . $_SESSION['size'] . '; '; echo 'color: ' . $_SESSION['color'] . ';" '; ?>> <?php echo $_SESSION['textformat']; ?> </p> </body> </html> Hi,
I am trying to redirect a page to another page based on if the page contains an image with an exact source.
I have this so far:
if ( $("span#bannerhold:has(img[src='http://www.website.com/images/banners/banner1.gif'])")){ location.href = "http://www.google.com" }However it doesn't seem to work. Any ideas why? Thanks! I want to update a value by setting cookie. I use this code: Code: [Select] <?php if (isset($_POST['ChangeOrdering'])) { setcookie("Ordering", $_POST['ChangeOrdering'], time() + 31536000); } echo $_COOKIE["Ordering"]; ?> <form method="post" action="<?php echo $_SERVER["PHP_SELF"] ?>"> Reorder messages: <select name="ChangeOrdering"> <option value="DateAdded ASC">Oldest first</option> <option value="DateAdded DESC">Newest first</option> <option value="Title ASC">By Title, A-Z</option> <option value="Title DESC">By Title, Z-A</option> </select> <input type="submit" value=" Save Settings " /> </form> Problem is that echo will return the previous cookie set, not the last value. As a matter of fact, my problem is about updating the cookie. It seems that the browser load the cookie before it is updated by the POST value. Hi everyone, I have a form which is repopulated with cookies of user entries following an unsuccessful submit. It works on all fields except the textarea which is just blank. Can anybody suggest why this isn't working? Here is the form page code: Code: [Select] <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <?php include("functions.php"); getcompanyname(company); ?> <html> <head> <title>Nominate <?php echo getuserdetails("company", company); ?> for The WOW! Awards</title> <link href="mobile.css" rel="stylesheet" type="text/css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script type="text/javascript" src="javascript/form.js"></script> </head> <div id = "header"> <img src="images/mobile_banner.png"); </div> <div id="content"> <?php mobileerror(); ?> <h2>NOMINATE US!</h2> <div id = "rulesheading"> <b>There are just four criteria to be met:</b><br /> </div> <div id = "rules"> <ol> <li>It has to be for service that made you go WOW!</li> <li>It should be a recent experience</li> <li>It must have happened to you personally</li> <li>Employees of LoveFilm may not nominate</li> </ol> </div> <form id= "contactform" action="mobile_proc_nominate.php" method="post"> <fieldset><legend>Nomination Form</legend> <input type="hidden" name="type" value="nomination"/> <input type="hidden" name="jobtitle" value=" "/> <input type="hidden" name="department" value=" "/> <input type="hidden" name="mobile" value="1" /> <h4>Your Nomination Details</h4> <p> <?php if (!isset($_COOKIE['nominee'])){ ?> <!-- These stop the Java labels overwriting user text if error --> <label for="nominee">Tell us who WOW!ed you today (required)</label> <?php } ?> <input type="text" name="nominee" id="nominee" value="<?php echo readcookie('nominee'); ?>" title="Tell us who WOW!ed you today"/> </p> <p> <?php if (!isset($_COOKIE['comment'])){ ?> <label for="comment">How, where and when did they WOW! you? (required)</label> <?php } ?> <textarea name="comment" id="comment" value="<?php echo $_COOKIE["comment"]; ?>" title="How, where and when did they WOW! you? (required)" /></textarea> </p> <h4>Your Details</h4> <p> <?php if (!isset($_COOKIE['name'])){ ?> <label for="name">Your Name (required)</label> <?php } ?> <input type="text" name="name" id="name" value="<?php echo readcookie('name'); ?>" title="Please tell us your name"/> </p> <p> <?php if (!isset($_COOKIE['email'])){ ?> <label for="email">Your Email (required)</label> <?php } ?> <input type="text" name="email" id="email" value="<?php echo readcookie('email'); ?>" title="Please enter your email address"/> </p> <p> <?php if (!isset($_COOKIE['phone'])){ ?> <label for="phone">Your Phone Number</label> <?php } ?> <input type="text" name="phone" id="phone" value="<?php echo readcookie('phone'); ?>" title="And your phone number"/> </p> <input class="button" type="submit" value="Send" /> </fieldset> </form> </div> <div id="footer"> </div> </body> </html> And here is the form processing script: Code: [Select] <?php include("functions.php"); checkaccess(0); require_once("includes/browser.php"); $browser = new Browser(); $thebrowser = ereg_replace("[^A-Za-z]", "", $browser->getBrowser()); $ver = $browser->getVersion(); setcookie("nominee",$_POST['nominee'],time()+3600); setcookie("comment",$_POST['comment'],time()+3600); setcookie("name",$_POST['name'],time()+3600); setcookie("email",$_POST['email'],time()+3600); setcookie("phone",$_POST['phone'],time()+3600); $email = $_POST['email']; if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $email_error="TRUE"; } if ($thebrowser.$ver != "InternetExplorer6.0") { /* if(!captcha() ) { header("location: nominate.php?err=Spam Protection Code"); } else*/ if($_POST['name']=="" || $_POST['name']=="Your Name (required)" || $_POST['nominee']=="Tell us who WOW!ed you today (required)" || $_POST['nominee']=="" || $_POST['comment']=="How, where and when did they WOW! you? (required)" || $_POST['comment']=="" || $_POST['email']=="" || $_POST['email']=="Your Email (required)" || $email_error=="TRUE" ) { header("location: mobile.php?err=Please complete the required fields"); } else { connect(); $name=format_text_for_database($_POST['name']); $email=format_text_for_database($_POST['email']); $phone=format_text_for_database($_POST['phone']); $nominee=format_text_for_database($_POST['nominee']); $jobtitle=format_text_for_database($_POST['jobtitle']); $department=format_text_for_database($_POST['department']); $comment=format_text_for_database($_POST['comment']); $type=format_text_for_database($_POST['type']); $cid=company; $mobile=format_text_for_database($_POST['mobile']); $sql=mysql_query("insert into comments (date, name, email, phone, department, nominee, jobtitle, comment, type, cid, mobile) values (now(), '$name', '$email', '$phone', '$department', '$nominee', '$jobtitle', '$comment', '$type', $cid, $mobile)"); $lastid=mysql_insert_id(); disconnect(); senduseremail($lastid); sendclientemail($lastid); header("location: mobile_thanks.php"); } } if ($thebrowser.$ver == "InternetExplorer6.0") { /* if(!captcha_spam() ) { header("location: nominate.php?err=Please re-enter the Spam Protection Code"); } else*/ if($_POST['name']=="" || $_POST['email']=="" || $_POST['comment']=="") { header("location: nominate.php?err=Please complete the required fields"); } else { connect(); $name=format_text_for_database($_POST['name']); $email=format_text_for_database($_POST['email']); $phone=format_text_for_database($_POST['phone']); $nominee=format_text_for_database($_POST['nominee']); $jobtitle=format_text_for_database($_POST['jobtitle']); $department=format_text_for_database($_POST['department']); $comment=format_text_for_database($_POST['comment']); $type=format_text_for_database($_POST['type']); $cid=company; $sql=mysql_query("insert into comments (date, name, email, phone, department, nominee, jobtitle, comment, type, cid) values (now(), '$name', '$email', '$phone', '$department', '$nominee', '$jobtitle', '$comment', '$type', $cid)"); $lastid=mysql_insert_id(); disconnect(); senduseremail($lastid); sendclientemail($lastid); header("location: mobile_thanks.php"); } } ?> Any pointers would be greatly appreciated. KN Hello, Please... could someone look at my existing code below at tell me how I can establish a REDIRECT PAGE {header("Location: thankyou.php");} to fit in my code and WITHOUT generating a MySQL error once the php page is processed on the server? I wish to place the HTML CODE at bottom of my page labeled " // THE RESULTS OF THE FORM RENDERED AS PURE HTML " to be on a separate " thanks.php " page. thanks mrjap1 Code: [Select] <?php $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $registration_date = $_POST['registration_date']; // 1. Create a database connection $con = mysql_connect("localhost","mrino_mydata","runns100"); if (!$con) { die('Database connection failed could not connect: ' . mysql_error()); } // 2. Select a database to use $db_select = mysql_select_db("mrino_FULLENTRYDATA",$con); if (!$db_select) { die('Database selection failed could not connect: ' . mysql_error()); } mysql_select_db("mrino_FULLENTRYDATA", $con); // Data Submitted With My Form $sql="INSERT IGNORE INTO `mrino_FULLENTRYDATA`.`backpage1` (`id` , `first_name` , `last_name` , `email` , `registration_date`) VALUES (NULL , '$_POST[first_name]' , '$_POST[last_name]' , '$_POST[email]', NOW( ))"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } // 3. Close Connection mysql_close($con); ?> <?php // ALL THE SUBJECT and EMAIL VARIABLES $emailSubject = 'MY TEST EMAIL SCRIPTING!!! '; $webMaster = 'myemailaddress@gmail.com'; // GATHERING the FORM DATA VARIABLES $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $registration_date = $_POST['registration_date']; $date = date ("l, F jS, Y"); $time = date ("h:i A"); $body = <<<EOD <br /><hr><br /> <strong>First Name:</strong> $first_name <br /> <strong>Last Name: </strong>$last_name <br /> <strong>Email:</strong> $email <br /> <strong>Registration Date:</strong> $date at $time <br /> EOD; // THIS SHOW ALL E-MAILED DATA, ONCE IN THE E-MAILBOX AS READABLE HTML // Remove Header Injections $match = "/(bcc:|cc:|content\-type:)/i"; if (preg_match($match, $from) || preg_match($match, $subject) || preg_match($match, $body)) { die("Header injection detected."); } // Simple filtering on all of our input variables $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); $from = preg_replace("([\r\n])", "", $_POST['email']); $emailSubject = preg_replace("([\r\n])", "", $_POST['$emailSubject']); // THE RESULTS OF THE FORM RENDERED AS PURE HTML $theResults = <<<EOD <!DOCTYPE HTML> <html lang="en"> <head> <style type="text/css"> body { font-family:Arial, Helvetica, sans-serif; font-size:11px; font-weight:bold; } #thankyou_block { width: 400px; height: 250px; text-align:center; border: 1px solid #666; padding: 5px; background-color: #0CF; border-radius:8px; -webkit-border-radius:8px; -moz-border-radius:8px; -opera-border-radius:8px; -khtml-border-radius:8px; box-shadow:0px 0px 10px #000; -webkit-box-shadow: 0px 0px 10px #000; -moz-box-shadow: 0px 0px 10px #000; -o-box-shadow: 0px 0px 10px #000; margin: 25px auto; } p { font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px; letter-spacing:1px; color: #333; } </style> <meta charset="UTF-8"> <title>THANK YOU!!!</title> </head> <body> <div id="thankyou_block"> <br><br><br> <h1>CONGRATULATIONS!!</h1> <h2>YOUR FORM HAS BEEN PROCESSED!!!</h2> <p>You are now registered in our Database...<br> we will get back to you very shortly.<br> Please have a very wondeful day.</p> </div> </body> </html> EOD; echo "$theResults"; ?> Hai Folks,
Please help me in this situation,
Actually my case is bit complicated
i have a list of few movies.please check the attached file.
If we click on each movies ,i want to direct into next page describing details of that clicked movie (review,image,syopsis,time).can you help me to write code
following is the code for showing movie list.
<?php hello, so i have this contact page on my website, but i want people to actually know if the mail got sent or not, so i first have contact.php, which sends all the information to sendmail.php, which in turn tells redirect.php wether or not the mail was sent, and redirect.php then shows this information for the user to see, and has a 10 second timer before users get sent back.. here is the website: http://hcg.drokz.eu.clanservers.com/ all files are in the same folder so here is my code: Code: (sendmail.php) [Select] <?php $url1 = 'redirect.php?sent=sent'; $url2 = 'redirect.php?sent=fail'; $timeout = 0; ?> <?php $to = "admin@hcg.drokz.eu.clanservers.com"; $name = $_REQUEST['name'] ; $subjectm = $_REQUEST['subject'] ; $subject = "contact form entry on the hcg website by $name with the subject $subjectm"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; ?> <?php if($sent) {header('Refresh: ' . $timeout . ';url=' . $url1); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url1); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url1); ?>";}, <?php echo($timeout * 1000); ?>); </script> <?php } ; ?> <?php else {header('Refresh: ' . $timeout . ';url=' . $url2); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url2); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url2); ?>";}, <?php echo($timeout * 1000); ?>); </script> <?php } ; ?> <a href='contact.php'> this page should redirect you, if nothing happens, click here! </a> Code: (redirect.php) [Select] <?php $sent = $_GET['sent'] ; ?> <?php $url = 'contact.php'; $timeout = 10; ?> <?php header('Refresh: ' . $timeout . ';url=' . $url); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url); ?>";}, <?php echo($timeout * 1000); ?>); </script> <h1> <?php if($sent == sent) {echo "Success!" } ; elseif($sent == fail) {echo "Failure!" } ; ?></h1> <?php if($sent == sent) {echo "your email has been sent successfully and we will reply as soon as we can."} ; elseif($sent == fail) {echo "we have encountered a problem while sending your email, please try again!"} ; ?> <p> <a href='contact.php'> this page will redirect you in 10 seconds, if nothing happens or you can't wait, click here! </a> Hello everyone, I am creating a site that has two modes 1.Default 2.under construction I use database to see weather the site is under construction or not. The template of under construction is different and is stored in a another directory eg: site url: www.my.com under construction page: www.my.com/uc now i want that when the database is selected for under construction the URL should show www.my.com not www.my.com/uc Please help me with this. I tried to redirect with header(location: '.......'); but in the URL it shows www.my.com/uc Thanks. I am a newbie to php.. Used to do work in Cold Fusion and I cannot figure out what I am doing with a registration page I have created. I am looking to have the page insert into two databases, which it is doing, and then redirect to the main member's page. I have been looking for something and have not found anything here or online that works for me. I understand that you cannot use header() after any type of html or echo, but I have tried .js and other methods. I am not throwing errors, just no redirect... Also I am interested in hearing how bad my code is... any positive criticism is appreciated, as I am still learning Here is my code: Code: [Select] <?php include("dbc.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Registration Page</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8"> <link rel="stylesheet" href="styles.css" type="text/css" charset="utf-8"> //Some Javascript... </script> </head> <body> //Some Styling... <!-- content goes here --> <h1>Register</h1> <?php ob_start(); error_reporting(0); $_POST = array_map('secure', $_POST); if($_POST['submit']) { $user_name = mysql_real_escape_string($_POST['user_name']); $query = mysql_query("SELECT * FROM xxxxusers WHERE user_name='$user_name'"); $query = mysql_query("SELECT * FROM xxxusers WHERE user_name='$user_name'"); if(mysql_num_rows($query) != 0) { echo "<div style="font-size: 9pt; font-weight: bold;color: red;">Username already exists</div>"; } else { $user_password = mysql_real_escape_string($_POST['user_password']); $user_pass = mysql_real_escape_string($_POST['user_pass']); $user_email = $_POST['user_email']; $query = mysql_query("SELECT * FROM xxxxusers WHERE user_email='$user_email'"); $query = mysql_query("SELECT * FROM xxxusers WHERE user_email='$user_email'"); if(mysql_num_rows($query) != 0) { echo "<div style="font-size: 9pt; font-weight: bold;color: red;">Email already exists</div>"; } else { $enc_password = md5($user_password); $enc_password = md5($user_pass); if($user_name && $user_password && $user_pass && $user_email) { if (strlen($user_name)>20) { echo "<div style="font-size: 9pt; font-weight: bold;color: red;">Your Name is Too Long</div>"; } $email = htmlspecialchars($_POST['user_email']); if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { echo "<div style="font-size: 9pt; font-weight: bold;color: red;">E-mail address not valid</div>"; } { require "dbc.php"; mysql_query("INSERT INTO xxxxusers stuff....) VALUES(stuff....) ") or die(mysql_error()); mysql_query("INSERT INTO xxxusers stuff....) VALUES(stuff....) ") or die(mysql_error()); } } else echo "<div style="font-size: 9pt; font-weight: bold;color: red;">All Fields Are Required</div>"; } } } ob_end_flush(); ?> <form action="register.php" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr> <td>Username:</td> <td><input type="text" name="user_name" maxlength="30" value="<?php echo "$user_name"; ?>"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="user_password" maxlength="30" value=""></td> </tr> <tr> <td>Confirm password:</td> <td><input type="password" name="user_pass" maxlength="30" value=""></td> </tr> <tr> <td>Email address:</td> <td><input type="text" name="user_email" maxlength="50" value=""<?php echo "$user_email"; ?>""></td </tr> <tr><td colspan="2" align="right"> <input type="submit" value="Register!" id="submit" name="submit"></td></tr> <tr><td colspan="2" align="left"><a href="index.php">Back to Home Page</a></td></tr> </table> </form> Afternoon All. I wish to re-direct users to a 404 error page on my site if an article does not exist in my database. Here's my code: $SQL = "SELECT headline FROM news WHERE news_id=".mysql_real_escape_string($_GET['news_id']); $result = mysql_query($SQL) OR die(mysql_error()); $num = mysql_num_rows($result); //** Check that the entry exists otherwise send to error page if ($num > 0) { $row = mysql_fetch_array($result); $headline = $row['headline']; } else { echo "Why is this printed? - I should be leaving this page?"; header("Location: error.php"); exit; } Now the wierd thing is that when I enter a news_id for a value that does not exist it prints the message Why is this printed? - I should be leaving this page? so it's actually going to the ELSE statement which is good, but surely it should not do this as I ask the page to re-direct? Thank you I have written some php that forces login before accessing certain pages on my site. When a user sends an private message to another user, they are notified via email. In the email they can then click the view message link to take them right to the message, but if they aren't logged in they are sent to the login page. I'd like them to be redirected to the message after logging in, but I'm getting a php error. This is currently working for URL's like: domain.com/known-bugs Does NOT work: http://domain.com/messaging?action=read&cid=130&utm_source=new_message&utm_medium=email&utm_campaign=direct_mesage_link I think the query string is a problem in the script. To create this login feature. I am using... Code: [Select] $login = array( 'blogadd', 'messaging', 'company-settings', 'company-landing', 'company-create', 'company-join', 'account-settings', 'logout', 'home', 'newsadd', 'partnerRequest', 'known-bugs', 'reminders' ); $page = substr(end(explode(DIRECTORY_SEPARATOR, $_SERVER['PHP_SELF'])), 0, -4); if (in_array($page, $login)) { $urlSource = urlencode(curPageUrl()); header("Location: /login?onlogin=${urlSource}"); die(); } curPageURL is just the full url of the current page. WORKS: When I'm not logged in and I go to the known-bugs page I get redirected to http://domain.com/login?onlogin=http%3A%2F%2Fdomain.com%2Fknown-bugs DOESN'T WORK: When I try and access messaging by clicking... http://domain.com/messaging?action=read&cid=130&utm_source=new_message&utm_medium=email&utm_campaign=direct_mesage_link I get redirected to: http://domain.com/login?onlogin=http%3A%2F%2Fdomain.com%2Fmessaging%3Faction%3Dread%26cid%3D130%26utm_source%3Dnew_message%26utm_medium%3Demail%26utm_campaign%3Ddirect_mesage_link Any thoughts as to what I am doing wrong? |