PHP - Header('content-type: Image/jpeg'); Not Working??
hi evry bdy i m new to php here is my big problem im trying to display images and resize but header tag in php not working here is my code <?php header('Content-type: image/jpeg'); $new_width = 200; $new_height = 200; $files = glob("images/*.*"); //print_r($files); //for ($i=0; $i<count($files); $i++) { $filename= $files[0]; print $filename."<br />"; list($width, $height) = getimagesize($filename); echo "width is".$width." and height is ".$height; echo '<img src="'.$filename.'" alt="random image" />'."<br /><br />"; $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p, null, 100); //} ?> if i m commenting header in line 3 then it is displaying garbage value if i m not commenting then it is displaying filename as string ... i wanna resize image please help me..... Similar TutorialsWeird question. I am using a captcha class which creates the code/image simply by doing this: Code: [Select] <img src="captcha.php"> The captcha.php file has lots of code of course, but this being key to my question: Code: [Select] header("Content-Type: image/jpeg"); ImageJpeg($image); Can I do it so I can create the image in the PHP of the actual script executing, so I don't have to call captcha.php in the image? - So it would look like this: (well no, but I think this explains what I want) Code: [Select] <img src="<?php echo $captchaCreated; ?>"> I am using a MVC design and don't see why the captcha should try and change this. Or should the Twig class be used to generate the content type header?
require_once '../../../vendor/autoload.php'; Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem('templates'); $twig = new Twig_Environment($loader, array('debug' => true,)); $twig->addExtension(new Twig_Extension_Debug()); header('Content-type: text/html; charset=utf-8'); echo $twig->render('myTemplate.html', array()); <?php require_once('init.php'); $results = $db->prepare('SELECT file_location, file_type, file_size, id as media_id WHERE id = ? LIMIT 1;'); $results->execute(array($_GET['id'])); while ($row = $results->fetch()) { header('Content-Type: ' . $row['file_type']); header('Content-Length: ' . $row['file_size']); $media_ins = $db->prepare('UPDATE media SET total_clicks = total_clicks + 1 WHERE id = ?'); $media_ins->execute(array($row['id'])); readfile($row['file_location']); }For some reason, putting the header('Content-Type....') causes the UPDATE statement to trigger twice increasing the total_clicks by 2. Commenting out the content-type line causes a single update to occur. init.php contains nothing more than session_start and the database connection. When i comment-out the content-type line the page is blank with no errors or messages. I'm not sure why this is occurring. this is the code <?php $image = imagecreatefromjpeg("9t4i_200xX.jpg"); $new_image = imagecreatetruecolor(120,90); imagecopyresampled($new_image, $image, 0, 0, 0, 0, 120, 90, imagesx($image), imagesy($image)); $image = $new_image; imagejpeg($image,"images/test.jpg"); ?> result is black jpeg image of size 120,90 I dont understand where could be the problem SimpleImage.php script doesnt work either For SEO purposes I am told that either 301/302 redirects are better. I use header("Location: $url everywhere, is this 301 or 302 ? Also, I see somewhere that this is the proper way to do it. Code: [Select] header ('HTTP/1.1 301 Moved Permanently'); header ('Location: '.$location); .. what if I didn't use the first line (I have sites all over the place littered with header Location, but have only used the 2nd line)? Would it make a difference - it works that's for sure. Hi, I am trying to get google docs viewer integrated into my website. It is working for ppt files but not pptx files. I have read up and I understand I need to alter the header to: header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); However when I do this I click on the link and it just downloads index.php. Any idea what I am doing wrong here? Hi All, I'm trying to upload a gif file via php/curl, and the browser keeps interpreting the content-type as application/xml. I've tried explicitly setting the content type, see below, but it has no effect. Any thoughts? I've seen conflicting posts on the ability to specify the content-type with curl/php. Code: [Select] curl_setopt($session, CURLOPT_HTTPHEADER, array( "Content-Type: image/gif", 'Content-length: ' . strlen($post) )); Hey guys, I know nothing of PHP so please bare with me as I try to explain my problem. My company collects sales leads that are emailed through to a CRM system (GoldMine). We are currently in the process of moving our website from a shared windows server to a dedicated linux server and it seems to be causing a problem with the form, or at least PHP behind it. The guy who handed the initial set up has mysteriously disapeared so we're in a bit of a fix. I'm not specifically looking for a solution, more of an idea of where to go from here. I'm not sure wether the problem lies in the PHP itself or something else.. like the server for example. I was hoping someone here might be able to point me in the right direction somewhat. Anyway, the problem is that while testing the form on the new server the email is sent and our CRM picks it up but cannot read because a newly appeared line has been inserted at the top of the body. This does not appear when filling in the form currently live on our site (windows server). the line is: Code: [Select] Content-Type: text/x-gm-impdata As far as I'm aware this content-type is necessary for our CMR to recognize and read the email, but it shouldn't be showing up in the body of the mail. The full on send PHP is: Code: [Select] <?php $redirectURL = "http://www.website.co.uk/confirmation_page.htm"; function Decode($strValueIn) { //Do not modify this function! $intX = 0; $intY = 0; $Temp = ""; $Mod = ""; $intMod =0; $intTemp = 0; $ValueOut = ""; $intY = 1; $strValueOut=""; for ($intX=1; $intX<=((strlen($strValueIn)/2)/2); $intX=$intX+1) { $strTemp=""; $strMod=""; if (($intX % 2)==0) { $strMod=substr(substr($strValueIn,$intY-1,4),0,2); $strTemp=substr(substr($strValueIn,$intY-1,4),strlen(substr($strValueIn,$intY-1,4))-(2)); } else { $strMod=substr(substr($strValueIn,$intY-1,4),strlen(substr($strValueIn,$intY-1,4))-(2)); $strTemp=substr(substr($strValueIn,$intY-1,4),0,2); } $intMod=hexdec($strMod); $intTemp=hexdec($strTemp); $intTemp=$intTemp-$intMod; $strValueOut=$strValueOut.chr($intTemp); $intY=$intY+4; } return $strValueOut; } if ($_POST["GMsubmit"]!="") { $Body = ""; $Notes = ""; $SendToEmail = Decode($_POST["SendToEmail"]); //$SMTP = Decode($_POST["SMTP"]); //Your SMTP data may have to be set set on the Apache Server, and this variable is not used. $OnNewSendGMEmail = $_POST["OnNewSendGMEmail"]; if ($OnNewSendGMEmail!="") {$OnNewSendGMEmail = Decode($OnNewSendGMEmail);} else {$OnNewSendGMEmail = "";} if ($_POST["OnDUPSendGMEmail"]!="") {$OnDUPSendGMEmail = Decode($_POST["OnDUPSendGMEmail"]);} else {$OnDUPSendGMEmail = "";} if ($_POST["OnNewAttachTrack"]!="") {$OnNewAttachTrack = Decode($_POST["OnNewAttachTrack"]);} else {$OnNewAttachTrack = "";} if ($_POST["OnDupAttachTrack"]!="") {$OnDupAttachTrack = Decode($_POST["OnDupAttachTrack"]);} else {$OnDupAttachTrack = "";} if ($_POST["Word"]!="") {$Password = Decode($_POST["Word"]);} else {$Password = "";} if ($_POST["DupLogic"]!="") {$DupLogic = Decode($_POST["DupLogic"]);} else {$DupLogic = "";} $OutputAs = $_POST["OutPutAs"]; $DuplicateCount=0; $XML = "<gmdata>"; if ($_POST["DuplicateCount"]!="") { $DuplicateCount =intval($_POST["DuplicateCount"]); } if ($DuplicateCount >0 || $OnNewSendGMEmail!="" || $OnDUPSendGMEmail!="" || $OnNewAttachTrack!="" || $OnDupAttachTrack!="") { $Body = $Body."[Instructions]\r\n"; $XML = $XML."<Instructions>"; if ($DuplicateCount > 0) { for($counter=0; $counter < $DuplicateCount; $counter++) { $RealCount=$counter+1; $str = "DuplicateChecking$RealCount"; eval("\$str = \"$str\";"); $Body = $Body."DupCheck".$RealCount."=".$_POST[$str]."\r\n"; //print($str.":".$_POST[$str].";"); $tempVal = $_POST[$str]; if ($tempVal==="EMAIL") { $XML = $XML."<DupCheck>EA1</DupCheck>"; } else { if ($tempVal==="WEBSITE") { $XML = $XML."<DupCheck>WS1</DupCheck>"; } else { $XML = $XML."<DupCheck>".htmlspecialchars($_POST[$str])."</DupCheck>"; } } } if ($DupLogic !="") {$Body = $Body."DupLogic=OR\r\n";} } if ($OnNewSendGMEmail!="") { $Body = $Body."OnNewSendGMEmail=".$OnNewSendGMEmail."\r\n"; $XML = $XML."<OnNewSendGMEmail>".htmlspecialchars($OnNewSendGMEmail)."</OnNewSendGMEmail>"; } if ($OnDUPSendGMEmail!="") { $Body = $Body."OnDUPSendGMEmail=".$OnDUPSendGMEmail."\r\n"; $XML = $XML."<OnDupSendGMEmail>".htmlspecialchars($OnDUPSendGMEmail)."</OnDupSendGMEmail>"; } if ($OnNewAttachTrack!="") { $comma =strpos($OnNewAttachTrack, ","); $Body = $Body."OnNewAttachTrack=".$OnNewAttachTrack."\r\n"; if ($comma =="") { $XML = $XML."<OnNewAttachTrack>".htmlspecialchars($OnNewAttachTrack)."</OnNewAttachTrack>"; } else { list($track, $user) = split(',', $OnNewAttachTrack,2); $XML = $XML."<OnNewAttachTrack User=".chr(34).htmlspecialchars($user).chr(34).">".htmlspecialchars($track)."</OnNewAttachTrack>"; } } if ($OnDupAttachTrack!="") { $comma =strpos($OnDupAttachTrack, ","); $Body = $Body."OnDupAttachTrack=".$OnDupAttachTrack."\r\n"; if ($comma =="") { $XML = $XML."<OnDupAttachTrack>".htmlspecialchars($OnDupAttachTrack)."</OnDupAttachTrack>"; } else { list($track, $user) = split(',', $OnDupAttachTrack,2); $XML = $XML."<OnDupAttachTrack User=".chr(34).htmlspecialchars($user).chr(34).">".htmlspecialchars($track)."</OnDupAttachTrack>"; } } if ($Password!="") { $Body = $Body."Password=".$Password."\r\n"; $XML = $XML."<Password>".htmlspecialchars($Password)."</Password>"; } if ($DupLogic!="") { $XML = $XML."<DupLogic>OR</DupLogic>"; } else { $XML = $XML."<DupLogic>AND</DupLogic>"; } $XML = $XML."</Instructions>"; } $Body = $Body."[Data]\r\n"; $XML = $XML."<accounts><account>"; $Phone = ""; $EA = ""; $WS = ""; $PR = ""; while(list($key,$value)= each($_POST)) { eval("$\$key = \"$value\";"); { if ($key!="GMsubmit" && $key!="SMTP" && $key!="OnNewSendGMEmail" && $key!="OnDUPSendGMEmail" && $key!="OnNewAttachTrack" && $key!="OnDupAttachTrack" && $key!="SendToEmail" && $key!="DuplicateCount" && $key!="Word" && strpos($key, "DuplicateChecking") === false && $key!="OutPutAs" && $key!="DupLogic" && strpos($key, "pretty_") === false) { if($value!="") { if ($key=="UHCUSTDESC" || $key=="UHDESCGOOD" || $key=="UHPI") { $value = str_replace("\r\n","<br/>",$value); $NoteHeader = ""; if ($key=="UHCUSTDESC") { $NoteHeader = "<strong>Customer Description</strong><br/><br/>"; } if ($key=="UHDESCGOOD") { $NoteHeader = "<strong>Descriptions of Goods</strong><br/><br/>"; } if ($key=="UHPI") { $NoteHeader = "<strong>Packing Information</strong><br/><br/>"; } $Notes = $Notes.$NoteHeader.$value."<br/><br/>"; } $Body = $Body.$key."=".$value."\r\n"; if (substr($key,0,5)!="PHONE" && substr($key,0,3)!="FAX" && substr($key, 0, 5)!="EMAIL" && substr($key,0, 7)!="WEBSITE") { $PR = $PR."<property name=".chr(34).$key.chr(34)." db_name=".chr(34).$key.chr(34).">"; $PR = $PR."<property_string>".htmlspecialchars($value)."</property_string>"; $PR = $PR."</property>"; } else { if(substr($key,0,5)=="PHONE") { $Phone = $Phone."<phone international=".chr(34)."0".chr(34)." type=".chr(34).$key.chr(34)." source_fld=".chr(34).$key.chr(34).">"; $Phone = $Phone."<properties><property name=".chr(34)."phone_number".chr(34)."><property_string>".$value."</property_string></property></properties>"; $Phone = $Phone."</phone>"; } elseif(substr($key,0,3)=="FAX") { $Phone = $Phone."<phone international=".chr(34)."0".chr(34)." type=".chr(34).$key.chr(34)." source_fld=".chr(34).$key.chr(34).">"; $Phone = $Phone."<properties><property name=".chr(34)."phone_number".chr(34)."><property_string>".$value."</property_string></property></properties>"; $Phone = $Phone."</phone>"; } elseif(substr($key,0,7)=="WEBSITE") { $WS = $WS."<website primary=".chr(34)."1".chr(34)." id=".chr(34)."WS1".chr(34).">"; $WS = $WS."<properties><property name=".chr(34)."web_site".chr(34)."><property_string>".$value."</property_string></property></properties>"; $WS = $WS."</website>"; } elseif(substr($key,0,5)=="EMAIL") { $EA = $EA."<email primary=".chr(34)."1".chr(34)." id=".chr(34)."EA1".chr(34).">"; $EA = $EA."<properties><property name=".chr(34)."email_address".chr(34)."><property_string>".$value."</property_string></property></properties>"; $EA = $EA."</email>"; } } } } } } if ($PR !="") {$XML = $XML."<properties>".$PR."</properties>";} if($Phone!="") { $XML = $XML."<phone_numbers>".$Phone."</phone_numbers>"; } if($EA!="") { $XML = $XML."<emails>".$EA."</emails>"; } if($WS!="") { $XML = $XML."<websites>".$WS."</websites>"; } $XML = $XML."</account></accounts></gmdata>"; $ToSubject="Web Import"; //The PHP built in function mail() will not raise or cause errors if it fails - so be sure that your PHP server is setup correctly! if( $OutputAs!="INI") { $Body = $XML; } //ini_set("SMTP", Decode($SMTP)); $Body = $Body."UHSUBDATE=".date("d/m/Y")."\r\n"; $Body = $Body."NOTES=".$Notes; if(mail(Decode($SendToEmail), $ToSubject, $Body, "From: GoldMine WebImport <no-reply@frontrange.com>\r\n\r\nContent-Type: text/x-gm-impdata\r\n\r\n" )) { //print "Your data has been recorded successfully!\r\n\r\n<!--\r\n".Decode($SendToEmail)."\r\n".$ToSubject."\r\n".$Body."\r\n\r\n".$OutputAs."\r\n\r\n-->"; header("location: ".$redirectURL); } else { print("There was a mailer failure.\r\n\r\n<!--\r\n".$Body."\r\n\r\n-->");} } else { echo "There was no form data passed."; } ?> Line 294 contains the text that's appearing in the email. Any ideas would be very, very much appreciated. I have piping set up, where when I send an e-mail to a certain address, a script executes. This script will parse the e-mail and will post the body of the e-mails (along with a picture, if attached) to a blog. This all works okay, except the problem I keep running into is when I send from different devices (desktop, Android phone, BlackBerry), the e-mails have different character sets or encoding. So one e-mail will show up just fine, and then the body of another will look something like this: Quote --90e6ba6e83a0846c8504926b9478 Content-Type: text/html; charset=ISO-8859-1 This is the content of the e-mail. --90e6ba6e83a0846c8504926b9478-- So what I'm wondering is if there is any way to detect the charset/encoding and automatically decode it properly? The only solution I have so far -- and I'm not very good with PHP, I'll admit -- is to just "hack" my way through, by using stristr() to see if the body contains certain characters (like "ISO-8859-1"), and then extracting the text that is in between, say, "ISO-8859-1" and "--". Of course, this is very crude, and has many problems on its own. So what I am looking for is if there is some sort of way to automatically get the body of an e-mail in plain text, regardless of whether the e-mail has an attachment, how it's encoded, or what mail client was used. Thanks for your time! Hi, I have an image handling php script which works fine here if the image is actually a readable format by the php program... Code: [Select] <?php //determine image type if($this->ext == 'jpeg' || $this->ext == 'jpg') { $imageObject = imagecreatefromjpeg($image); } elseif($this->ext == 'gif') { $imageObject = imagecreatefromgif($image); } ?> However, I tested the script with a random gif created in photoshop and i got an ugly php error returned saying the image was not the correct type for imagecreatefromgif even tho the image was a .gif file. In response I then tried to make a safety test, but it doesn't seem to work: Code: [Select] <?php //determine image type if($this->ext == 'jpeg' || $this->ext == 'jpg') { if(imagecreatefromjpeg($image)) { $imageObject = imagecreatefromjpeg($image); } else{ //now remove the old TEMP file ($image) unlink($image); return 'Sorry there is a file type error with the image you are uploading.';*/ } } elseif($this->ext == 'gif') { if(imagecreatefromjpeg($image)) { $imageObject = imagecreatefromgif($image); } else{ //now remove the old TEMP file ($image) unlink($image); return 'Sorry there is a file type error with the image you are uploading.';*/ } } ?> The $image can be either a jpg jpeg gif or png... Could anyone please tell me how to correctly check if the file is in readable by the php program in this context? Any help would be very much appreciated Is there a diffrent image type refference in php for the file extentions 'jpg' & 'jpeg'. For example i have allowed "image/jpeg" files to be uploaded but only files with the extention .jpg are going through were as .jpeg are not, any idea's? I've made a Login Script and I'm trying to make it re-direct me to the Homepage after the login is complete. However, it's doing nothing at all... Code: [Select] <?php require('./includes/header.php'); require('./includes/functions.php'); ?> <div id="loginHolder"> <div id="title"></div> <h2>Login</h2> <hr /> <?php if(@$_POST['submit_login']) { echo '<div id="loginBox">'; $username = protect($_POST['username']); $password = protect(encrypt($_POST['password'])); $loginCheckQ = mysql_query("SELECT * FROM `users` WHERE `username`='".$username."'"); $loginCheckF = mysql_fetch_assoc($loginCheckQ); $dbusername = $loginCheckF['username']; $dbpassword = $loginCheckF['password']; if($username == $dbusername && $password == $dbpassword) { $_SESSION['loggedUser']=$username; echo '<font color="green">You have successfully logged in as '.$username.'.</font>'; header('location: index.php'); } else { echo '<span>Incorrect Username or Password.</span>'; } echo '</div>'; } ?> <form action="login.php" method="POST" autocomplete="off"> <table cellspacing="0" cellpadding="0"> <tr> <td>Username: </td><td><input type="text" name="username" /></td> </tr> <tr> <td>Password: </td><td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Login" class="submit" name="submit_login" /></td> </tr> </table> </form> </div> <?php require('./includes/footer.php'); ?> It works perfectly fine on Localhost, but when I upload it, it doesn't work. this little piece of code doesn't seem to work: Code: [Select] if($rs_teamcheck['team_id'] != $team{ header( "Location: http://domain/page.php" ) ;} If I replace the header location part with an echo the output is fine, so why isn't the redirect working? I have an html login page. Once a user is verified through the PHP page they get redirected to another page. For some reason once I have validated that the user exists I get the message that is was successful but the page will not redirect. This is my script I use on my HTML page to pass the parameters: Code: [Select] $(document).ready(function() { $('#submit').click(function() { var username = $('input[name=username]'); var password = $('input[name=password]'); var data = 'username=' + username.val() + '&password=' + password.val(); .ajax({ url: "login.php", type: "GET", data: data, cache: false, success: function() { alert("SUCCESS"); } }); return false; }); }); And this is my PHP page: Code: [Select] <?php $username = ($_GET['username']) ? $_GET['username'] : $_POST['username']; $password = ($_GET['password']) ? $_GET['password'] : $_POST['password']; if ($_POST) $post=1; $userFound = false; $memberId = ""; // Create connection string, Note, params are as follow // mysql_connect(databaseLocation, username, password) $con = mysql_connect("localhost","root",""); if (!$con) { die("Could not connect: " . mysql_error()); } mysql_select_db("memberdb", $con); // SQL Query $result = mysql_query("SELECT memberId, firstName, lastName, username, password FROM member"); while($row = mysql_fetch_array($result)) { if ($username == $row["username"] && $password == $row["password"]) { echo "<h1>Welcome " . $row["firstName"] ." ". $row["lastName"] . "! </h1></br>"; $userFound = true; $memberId = $row["memberId"]; } } // If User is found, continue on to next page, if not redirect to index.html if ($userFound) { echo "<h2>Login Successful</h2>"; echo "<h3>Page will redirect</h3>"; header( "url=menu.html?memberId=" . $memberId); } else { echo "<h2>LOGIN FAILED</h2>"; echo "<h3>Page will redirect</h3>"; header( "refresh: 1; url=index.html#loginPage"); } ?> It does the echo successfully but hangs on the part where is says : Quote header( "url=menu.html?memberId=" . $memberId); How can I get it to redirect? Thanks Hello! This is the code for the header of my blog. It isn't displaying the CSS correctly, and the links aren't working. I think there is something wrong with the PHP, but am totally blind. Any ideas? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <title><?php wp_title('//', true, 'right'); ?> <?php bloginfo('name'); ?></title> <meta name="description" content="<?php bloginfo('description'); ?>" /> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" /> <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/colours.css" type="text/css"/> <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?> <?php wp_head(); ?> </head> <body id="top" class="<?php echo setColourScheme(); ?>"> <div id="header"> <div class="blog-name"><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></div> <div class="description"><?php bloginfo('description'); ?> </div> <ul id="menu"> <li><a href="<?php echo get_option('home'); ?>/" <?php if(is_home()) {echo 'class="selected"';} ?>>HOME</a></li> <li><a href="http...com">MAG</a></li> <li><a href="http...com">ABOUT</a></li> <li class="last"><a href="http...com">SUBSCRIBE</a></li> </ul> <div class="clearboth"><!-- --></div> </div> </body> Thanks so much! Elvia I dont understand why my header(Location) isnt working. Does any one see why?
<?php include 'core/init.php'; logged_in_redirect(); include 'includes/overall/header.php'; if (empty($_POST) === false) { $required_fields = array('first_name', 'last_name', 'username', 'password', 'password_again', 'email'); foreach($_POST as $key=>$value) { if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = 'All field are required'; break 1; } } if (empty($errors) === true) { if (user_exists($_POST['username']) === true) { $errors[] = 'Sorry, the user \'' . $_POST['username'] . '\' is already taken'; } if (preg_match("/\\s/", $_POST['username']) == true) { $errors[] = 'Your username can not have spaces'; } if (strlen($_POST['password']) < 6) { $errors[] = 'Your password must be at least 6 characters long'; } if ($_POST['password'] !== $_POST['password_again']) { $errors[] = 'Your passwords do not match'; } if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'A valid email address is required'; } if (email_exists($_POST['email']) === true) { $errors[] = 'Sorry, the email \'' . $_POST['email'] . '\' is already is use. Please contact your site adimn is this is incorrect.'; } } } if (isset($_GET['success']) && empty($_GET['success'])) { echo '<div class="container"><div class="background-success text-center"><div class="alert alert-success center-background">You\'ve be registered successfully! Please check your email to activate your account</div><div class="center-background"><div class="center-text-background">if any issues occur please send us an email!! support@bettergamerzunited.com</div></div></div>'; } else { if(empty($_POST) === false && empty($errors) === true) { $register_data = array( 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'username' => $_POST['username'], 'password' => $_POST['password'], 'email' => $_POST['email'], 'email_code' => md5($_POST['username'] + microtime()) ); register_user($register_data); header('Location: register.php?success'); exit(); } ?> <div class="container background"> <form action="" method="POST" class="form-horizontal" role="form"> <div class="form-group"> <label for="inputfirstname3" class="col-sm-2 control-label">First Name</label> <div class="col-sm-10"> <input type="text" name="first_name" class="form-control" id="inputfirstname3" value="" autocomplete="off" placeholder="First Name"> </div> </div> <div class="form-group"> <label for="inputlastname3" class="col-sm-2 control-label">Last Name</label> <div class="col-sm-10"> <input type="text" name="last_name" class="form-control" id="inputlastname3" value="" autocomplete="off" placeholder="Last Name"> </div> </div> <div class="form-group"> <label for="inputusername3" class="col-sm-2 control-label">Username</label> <div class="col-sm-10"> <input type="text" name="username" class="form-control" id="inputusername3" value="" autocomplete="off" placeholder="Username"> </div> </div> <div class="form-group"> <label for="inputemail3" class="col-sm-2 control-label">Email</label> <div class="col-sm-10"> <input type="email" name="email" class="form-control" id="inputemail3" value="" autocomplete="off" placeholder="Email Address"> </div> </div> <div class="form-group"> <label for="inputpassword3" class="col-sm-2 control-label">Password</label> <div class="col-sm-10"> <input type="password" name="password" class="form-control" id="inputpassword3" autocomplete="off" placeholder="Password"> </div> </div> <div class="form-group"> <label for="inputpassword_again3" class="col-sm-2 control-label">Validate Password</label> <div class="col-sm-10"> <input type="password" name="password_again" class="form-control" id="inputpassword_again3" autocomplete="off" placeholder="Validate Password"> </div> </div> <div class="form-group"> <div class="col-sm-10"> <p class="info">Please be aware that this does not mean that you are a member of Better Gamerz United. If you would like to be come a member please contuine with the registration and then fill out our application. Other wise you will have limited use of this site. Thank you Team BGU!! </p> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-primary pull-right register">Register</button> </div> </div> </form> </div> <?php } include 'includes/overall/footer.php'; ?> I've got an issue with a header redirect that is confusing me. I haven't been able to find any similar problems that have help me solve it and the PHP man page on headers isn't helping me either. <?php if(isset($_POST['add_cat'])) { $cat_obj->add_category($_POST['cat_title']); header("Location: admin/category.php"); } ?> This code is in a file called add_category.php which is in the same directory as the category.php file I want it to redirect to. without the 'header..' line it works perfectly; but with the 'header..' line I get the following warning - QuoteWarning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/**/**/admin/add_category.php:2) in /opt/lampp/htdocs/**/**/admin/add_category.php on line 30
but there's no other place sending headers (that I can see) and to my inexperienced eye it seems like it's cyclical logic as it's saying the same line I want to send the redirect is the one that already sent it. Would someone mind giving me an ELI5 breakdown of why this isn't working properly and maybe a route to solving the problem, please? TIA Hello, When i want a custom site search i need to process like google "site:600host.net terms" however my php just pulls a blank page when trying to output this i think its to do with : Quote <?php $keywords = $_REQUEST["keywords"]; $keywords2 = "$keywords"; $lowerCase = strtolower($keywords2); header("Location: ".$lowerCase.".html"); ?> Thanks any help appreciated! this code works if i use the header() in the else section it doesnt but it will echo the commented part Code: [Select] <? /** * User has already logged in, so display relevant links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){ echo "<li>Logged In "; echo "<b>$session->username</b></li>"; if($session->isAdmin()){ echo "<li><a href=\"LoginSystem/admin/admin.php\">Admin Center</a></li>"; } echo "<li><a href=\"../LoginSystem/process.php\">Logout</a</li>"; } else{header("Location: ../LoginSystem/main.php"); //echo "<li><a href=\"../LoginSystem/process.php\">Login</a></li>"; } ?> Friends on my few php scripts i used header('Location: somefile.php'); which worked just fine until yesterday the redirects stopped to work, im on a shared web hosting and the hosting people said they made no changes to their server, i tried error reporting but no error shows the pages which should actually do the redirection displays a blank page with no error warnings on it.
what could be the issue any idea?
|