PHP - Newbie Taken Over Site - Registration Php Broken?
Hey folks.
okay, I took over the admin of a website ( http://www.annualclownsdirectory.com ) a while back. I have changed nothing in the php but there seems to be a problem with account activation. As a total newbie with php (I can work out what things do by reading the code, and can notice obvious mistakes but thats about it...) I have NO idea what is going on here to stop it working. If I make a test account the email is sent to me with the link to click on to activate the account, which looks like this: " http://www.annualclownsdirectory.com/confirm.php?id=330&hash=c6efb8f1d00beef170bd0df223ab87f1 " but when clicked the website throws up this: "Sorry, either this account is already active or it cannot be found, try logging in. If you have just created this account and are getting this error then please wait a couple of minutes and try again" Now when I check in myphpadmin the account is there, it's status is "unconfirmed" and I can't see anything wrong with the code (but as I say I am a total fresher here lol). I have attached register.php so you can see what is there. I can see no "md5" variable in the phpmyadmin section for clown_account. If any other files are needed please just say! And again, apologies for being useless! Sam / Bifford Similar TutorialsHello, I work for a non-profit agency and I have been up all night trying to fix a registration form that has suddenly stopped working after a php upgrade from v 5.0 to v 5.2. The server admin says it is my coding. When you hit submit the form actually does what it is supposed to however the missing link here is that I am not being emailed after each registration with the registraiton informationl. You can see the form in action at www.nctt.net/coreTest.php I have also cut and pasted the contents of that file below and have attached it to this email. There is also the last version of the form I used still up on the website that I never took down after our summer program. There are a few modifications to this page to meet the program requirements but in July www.nctt.net/SIReg.php was working fine. Any assitance, hints, suggestions, anything at all is welcome and I thnk you in advance for taking a loot. Jennifer <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>NCTT Registration Form</title> <style type="text/css"> body { margin: 10px padding: 0; font-size: 100%; } * { } h1.register { text-align: center; padding: 18px; background: #cc0033; color: #ffffff; font: 160% Arial, Helvetica, sans-serif; font-weight: bold; text-transform: uppercase; } h1.costs { margin: 10px 0 0 0; padding: 0; border-bottom: 5px solid #cccccc; font: 320% Arial, Helvetica, sans-serif; color: #0071b7; font-weight: bold; text-transform: uppercase; line-height: 1.5em; text-align: left; } h1.title { margin: 10px 0 0 0; padding: 0; border-bottom: 5px solid #cccccc; font: 180% Arial, Arial, Helvetica, sans-serif; color:#0071b7; font-weight: bold; text-transform: uppercase; line-height: 1.5em; text-align: left; } h1.regbox { color: #cc0033; font: 200% Trebuchet Ms, Arial; letter-spacing: -1px; margin: 0; padding: 0; text-align: center; } h1.side { letter-spacing: -1px; text-align: center; font: 140% Arial, Helvetica, sans-serif; font-weight: bold; color: #ffffff; padding: 0; margin: 0; } h2 { text-align: left; margin: 0; padding: 0; line-height: 1.8em; color: #cc0033; font-size: 170%; font-family: trebuchet ms; } h2.regbox { color: #0071b7; font: 140% Trebuchet Ms, Arial; letter-spacing: -1px; font-weight: bold; margin: 5px 0 0 0; padding: 0; text-align: center; } h2.enroll { color: #0071b7; font: 120% Trebuchet Ms, Arial; font-weight: bold; text-align: left; border-bottom: 3px solid #cccccc; margin: 15px 0 0 0;} h3 { margin: 0; padding: 0; line-height: 1.8em; color: #cc0033; font-size: 110%; font-family: trebuchet ms; } h4 { margin: 0; padding: 0; line-height: 1.8em; color: #cc0033; font-size: 90%; font-family: trebuchet ms; } p.normal { text-align: left; font: 75% Arial, Helvetica, sans-serif; line-height: 1.4em; margin: 5px; padding: 0; color: #000000; } .prices { border-bottom: 1px solid #ccc; color: #cc0033; line-height: 2em; font: 80% Arial, Helvetica, sans-serif; margin: 0; padding: 5px; } p.special { text-align: left; padding: 10px; margin: 5px 0 5px 0; background-color: #efefef; border: 1px solid #0071b7; font: 80% Arial, Helvetica, sans-serif; line-height: 1.5em; } p.normal1 { text-align: center; font: 75% Arial, Helvetica, sans-serif; line-height: 1.4em; margin: 5px; padding: 0; color: #000000; } span.price { border-bottom: 1px solid #ccc; color: #0071b7; line-height: 2em; font: 80% Arial, Helvetica, sans-serif; margin: 0; padding: 5px; } td.reg { background: #0071b7; border-bottom: 5px solid #0071b7; color: #ffffff; font-family: Arial, Helvetica, sans-serif; font-size: 150%; font-weight: bold; text-transform: uppercase; letter-spacing: -1px; } td.reg-line { border-bottom: 5px solid #0071b7; } td.title { font: 100% Arial, Helvetica, sans-serif; color: #000000; font-weight: bold; } label { font: 100% trebuchet ms, arial; color: #0071b7; font-weight: bold; } input { margin: 0; padding: 5px; } input.sub { padding: 10px; font-family: arial; color: #000033; font-size: 12pt; font-weight: bold; background: #ccc; text-transform: uppercase; } .success { color: #ffffff; background: #0071b7; font-weight: bold; font: 100% arial; border: 1px solid #000; padding: 10px; } .error { color: #fff; background: #FF0000; padding: 10px; border: 1px solid #990000; font: 90% arial; } a:link { text-align: left; font: 125% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bold; padding: 0; color: #cc3333; text-decoration: underline; } a:active {text-align: left; font: 125% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bold; padding: 0; color: #ff9933; text-decoration: none; } a:visited {text-align: left; font: 125% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bold; padding: 0; color: #009933; text-decoration: underline; } a:hover {text-align: left; font: 125% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bold; padding: 0; color: #0099ff; text-decoration: none;} p.check {text-align: left; font: 110% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bolder; padding: 0; color: #cc0033; } </style> </head> <body> <center> <? if($_POST['submit']) { $first = $_POST['first_name']; $last = $_POST['last_name']; $middle = $_POST['middle_name']; $dob = $_POST['dob']; $module_1 = $_POST['module_1']; /*$module_2 = $_POST['module_2'];*/ $province = $_POST['province']; $address_1 = $_POST['address_1']; $address_2 = $_POST['address_2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $school = $_POST['school']; $country = $_POST['country']; $taught = $_POST['taught']; $grade = $_POST['grade']; $home = $_POST['home']; $work = $_POST['work']; $email = $_POST['email']; if(!empty($first) && !empty($last) && !empty($address_1) && !empty($city) && !empty($state) && !empty($zip) && !empty($home) && !empty($email)) { if($module_1) { $cost = $cost+195; $add_email .= "<li>December 5, 2014: YES ($195)</li>"; } /* if($module_2) { $cost = $cost+1075; $add_email .= "<li>Week II: YES ($1075)</li>"; } if(date("n") <= 15) { $before = $cost*.05; $before = round($before,2); $cost = $cost-$before; } */ $msg .= "<body style=\"font-family: arial; font-size: 10pt; line-height: 1.5em;\">"; $msg .= "<p>These are the registration details submitted from the website.</p>"; $msg .= "<ul>"; $msg .= $add_email; $msg .= "<li><strong>Name:</strong> " . $first . " " . $middle . " " . $last . "</li>"; $msg .= "<li><strong>Address One:</strong> " . $address_1 . "</li>"; $msg .= "<li><strong>Address Two:</strong> " . $address_2 . "</li>"; $msg .= "<li><strong>City:</strong> " . $city . "</li>"; $msg .= "<li><strong>State:</strong> " . $state . "</li>"; $msg .= "<li><strong>Zipcode:</strong> " . $zip . "</li>"; $msg .= "<li><strong>Province:</strong> " . $province . "</li>"; $msg .= "<li><strong>Country:</strong> " . $country . "</li>"; $msg .= "<li><strong>School:</strong> " . $school . "</li>"; $msg .= "<li><strong>Grade Taught:</strong> " . $grade . "</li>"; $msg .= "<li><strong>Field/Subject Taught:</strong> " . $taught . "</li>"; $msg .= "<li><strong>Home Phone:</strong> " . $home . "</li>"; $msg .= "<li><strong>Work Phone:</strong> " . $work . "</li>"; $msg .= "<li><strong>Email:</strong> " . $email . "</li>"; $msg .= "</ul>"; $msg .= "<p>Total Cost: $" . $cost . "</p>"; /* if($before) { $msg .= "<p>This was sent before April 15, 2013, so 5% has been taken off the total.</p>"; }*/ $msg .= "</body>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; $headers .= 'From: donotreply@nctt.net'; $to = "info@nctt.net"; $subject = "Registration Form | " . $first . " " . $middle . " " . $last; mail($to,$subject,$msg,$headers); ?> <div class="success"> We have successfully sent your registration details to NCTT. Please click on "Add to Cart" below, and checkout with Paypal to complete your resgistration. <strong>Space will not be held for registration without payment unless you have contacted the office at 417-773-1654 and spoken to Jennifer to make special arrangements.</strong> <br /> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="info@nctt.net"> <input name="item_name" type="hidden" class="title" value="Registration: Critical Thinking, Reading, Writing and the Common Core "> <input type="hidden" name="amount" value="<? echo $cost; ?>"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="no_shipping" value="1" /> <input type="hidden" name="on0" value="name"> <input type="hidden" name="os0" maxlength="60" value="<? echo $first . " " . $middle . " " . $last; ?>"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <input type="hidden" name="add" value="1"> </form><!--<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="info@nctt.net"> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_viewcart_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <input type="hidden" name="display" value="1"> </form>--> </div> <? } else { echo "<div class=\"error\">Sorry, please fill out all of the required fields.</div>"; } } else { ?> <form action="core.php" method="post"> <table border="0" cellpadding="5" cellspacing="0" width="80%"> <tr> <td colspan=3><h1 class="costs"><div align="center">REGISTER ONLINE</div></h1></td> </tr> <tr> <td width=10%></td> <td width="90%" valign="top"> <table border=0 cellpadding=3 cellspacing=0 width="100%"> <tr> <td class="prices" align="left"><a href="core.htm">Critical Thinking, Reading, Writing and the Common Core</a> <br /><p>December 5, 2014</p></td> <td width="30%" align="right" class="prices"><p style="font-weight:bold; color:#cc3300; font-size:14px;">$195.00</p></td> </tr> </table> </td> <td width=20%></td> </tr> </table> <table border="0" cellpadding="5" cellspacing="0" width="80%"> <tr> <td width="50%" align="center" class="reg">Registration</td> </tr> </table> <table border="0" cellpadding="5" cellspacing="0" width="80%"> <tr> <td width=17%></td> <td width="66%" valign="top"> <div align="center"><h1 class="title">Critical Thinking, Reading, Writing and the Common Core</h1></div> <p class="check">You <i>must check</i> the box below for your registration to be valid. Thank you.</p> <input type="checkbox" name="module_1" value="1" /> <label for="module_1">Critical Thinking, Reading, Writing and the Common Core</label> <!--<table border="0" cellpadding="3" cellspacing="1" width="100%"> <tr> <td width="25%" valign="top"> <p style="font-weight:bold; font-size:14px; color:#cc3300;">December 6, 2013 $150.00</p> </td> <td width="25%"></td> </tr> <tr> <td width="25%"><input type="checkbox" name="module_1" value="1" /> <label for="module_1">Critical Thinking, Reading, Writing and the Common Core</label></td> <td></td> </tr> <tr> <td width="25%" valign="top"> <h4>Week II ($1075.00)</h4> </td> <td width="25%"></td> </tr> <tr> <td width="25%"><input type="checkbox" name="module_2" value="1" /> <label for="module_2">Summer Institute Week II</label></td> <td></td> </tr> </table>--> <hr size=1 width=100% noshade /> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td width="33%" align="center"><input type="text" name="first_name" size="30" /></td> <td width="33%" align="center"><input type="text" name="middle_name" size="30" /></td> <td width="33%" align="center"><input type="text" name="last_name" size="30" /></td> </tr> <tr> <td width="33%" align="center"><p class="normal1">First Name</p></td> <td width="33%" align="center"><p class="normal1">Middle Initial</p></td> <td width="33%" align="center"><p class="normal1">Last Name</p></td> </tr> </table> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <td><p class="normal">Address 1</p></td> <td colspan="3" align="left"><input type="text" name="address_1" size="94" /></td> </tr> <tr> <td><p class="normal">Address 2</p></td> <td colspan="3" align="left"><input type="text" name="address_2" size="94" /></td> </tr> <tr> <td><p class="normal">City</p></td> <td align="left"><input type="text" name="city" size="20" /></td> <td><p class="normal">State</p></td> <td align="left"><input type="text" name="state" size="20" /></td> </tr> <tr> <td><p class="normal">Zip</p></td> <td align="left"><input type="text" name="zip" size="20" /></td> <td><p class="normal">Province</p></td> <td><input type="text" name="province" size="20" /></td> </tr> <tr> <td><p class="normal">School/College</p></td> <td align="left"><input type="text" name="school" size="56" /></td> <td><p class="normal">Country</p></td> <td><input type="text" name="country" size="20" /></td> </tr> <tr> <td><p class="normal">Field/Subject Taught</p></td> <td align="left"><input type="text" name="taught" size="56" /></td> <td><p class="normal">Grade</p></td> <td><input type="text" name="grade" size="20" /></td> </tr> <tr> <td><p class="normal">Telephone (H)</p></td> <td align="left"><input type="text" name="home" size="20" /></td> <td><p class="normal">(W)</p></td> <td><input type="text" name="work" size="20" /></td> </tr> <tr> <td><p class="normal">Email Address</p></td> <td colspan="3"><input type="text" name="email" size="94" /></td> </tr> <tr> <td colspan=4 align=center><input type="submit" name="submit" value="Submit Form" class="sub" /></td> </tr> </table> <td width=17%></td> </td> </tr> </table> </form> <? } ?> </center> </body> </html>Attached Files coreTest.php 15.99KB 2 downloads SIReg.php 15.08KB 2 downloads registration.php Code: [Select] <html> <body> <form name="register" method="post" action="login.php" //onsubmit="return a()"> <table border='0'> <tr><td>Username:</td><td><input type='text'name='username' maxlength='60'></td></tr> <tr><td>Password:</td><td><input type='password' name='pass' maxlength='10'></td></tr> <tr><td>Confirm Password:</td><td><input type='password' name='pass2' maxlength='10'></td></tr> <tr><th colspan=2><input type='submit' name='sub' value='Register'></th></tr> </table> </form> <body> </html> and this direct to login page where the code is Code: [Select] <?php mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("Regis") or die(mysql_error()); if (isset($_POST['sub'])) { $message=strip_tags($message); if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) { echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('You did not complete all of the required fields')</SCRIPT>"); return false; } // checks if the username is in use if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']); } $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM registration WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { print ('Sorry, the username '.$_POST['username'].' is already in use.'); } if ($_POST['pass'] != $_POST['pass2']) { print ('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } // now we insert it into the database if($_POST['username'] && $_POST['pass'] && $_POST['pass2'] ) { $insert = "INSERT INTO registration (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; $add_member = mysql_query($insert); echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('Registration had been succesfully added :)')</SCRIPT>"); } } //if the login form is submitted /* if (isset($_POST['submit'])) { // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM registration WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. <a href=register.php>Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } } } else { // if they are not logged in ?> <form action="submit.php" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td><a href=register.php>Register</a></td> <td><input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } */ ?> My problem is when the code is reading this statement if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) { echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('You did not complete all of the required fields')</SCRIPT>"); return false; } ya it is appear that alert box but it will direct to login page im want it to be in registration page any modification on my code? Hi Folks. Ive looked around the forums, but im still unsure about the correct methods for constructing a multilanguage site. The site will be databse driven, and the database table (in this exmaple content) would be; Code: [Select] CONTENT id | Pageid | Language | Title | maintext 1 | 1 | En | English title | English text 2 | 1 | It | Italian title | Italian text 3 Initially, it would be just 2 languages, however, thinking laterally, this may increase in the near future. Now, questions... What would be the best way to set the default language of the site (italian) ...something like... Code: [Select] <?php SESSION_START(); if (isset($_GET['lang'])) { $lang=$_GET['lang']; $_SESSION['lang'] = $lang; } if(!isset($_SESSION['lang'])){ $lang="it"; }else{ $lang = $_SESSION['lang']; } ?> For the language buttons, is it good practice to use; Code: [Select] <a href="?lang=it">Italiano</a> to set the SESSION? Many thanks in advance I am creating a site to display some products. For ease of updating I want it to run off a MySQL database. I have created the database and php scripts to output and input data etc. I know want to show that data in my web pages. My question is.... Is it best to insert HTML into the php output script to display the information and make the site look how I want....OR ....... should I create a template of the site in HTML and then somehow call the php output script (and the particular row of the database...) Basically... should I put the html code into the php - OR - put the php into the HTML?? I hope this make sense...... thanks I get a php error...Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given $sql = "SELECT `pm_messages`.`conversation_id` FROM `pm_messages` GROUP BY `pm_messages`.`conversation_id` WHERE `pm_messages`.`conversation_id` = ${conversation['id']}"; $result = mysql_query($sql); $replies = mysql_fetch_assoc($result); this doesnt work and ive spent ages trying to figure it out
its the bit with else
<?php //CORS header header("Access-Control-Allow-Origin: *"); //Capture parameter $create = $_POST['create']; $fuser = $_POST['fuser']; if (!file_exists("uploads/$fuser/$create")); { if ($f = fopen("uploads/$fuser/$create", 'w')) { fwrite($f, 1); fclose($f); echo 'OK'; } } else { $f = fopen("uploads/$fuser/$create", 'w') fwrite($f, 5); fclose($f); echo 'FAIL' ; } ?>this bit does work below, its until i try to do else if , or else <?php //CORS header header("Access-Control-Allow-Origin: *"); //Capture parameter $create = $_POST['create']; $fuser = $_POST['fuser']; if (!file_exists("uploads/$fuser/$create")); { if ($f = fopen("uploads/$fuser/$create", 'w')) { fwrite($f, 1); fclose($f); echo 'OK'; } }help I copied the code for password_hash at php.net: <?php /** * In this case, we want to increase the default cost for BCRYPT to 12. * Note that we also switched to BCRYPT, which will always be 60 characters. */ $options = [ 'cost' => 12, ]; echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options); ?> and changed it for use in my login page:
$options = ['cost' => 12,]; $user = mysqli_real_escape_string($db_link,$_GET['username']); $pass = password_hash($_GET['password'], PASSWORD_BCRYPT, $options); but my page keeps saying invalid user/pass. Upon echoing the $pass I find that the result changes EACH time. so I created a test page that runs the code from php.net (verbatim code) 20x and I got: [pre]
$2y$10$Nlf0J520viR4C5jd3nIdd.6M3OMKACx503Jm3PiXDYZIs.13XAheq [/pre] Is password_hash broken? or am I mistaken to think that it's supposed to return the same output everytime fror the same input? Edited March 17, 2019 by Karaethontypos corrected Much of the PHP documentation is broken into very small pages. I find that this makes it very difficult to use. Does anyone else find this? I have a hackish but useful program which takes the PHP single-file documentation and splits it into one page per extension, ensuring that links between pages work correctly. It works quite well. I wonder if anyone else would find this useful? If so, then I should have time in the next few weeks to clean it up and make it publicly available. So on my website I have a basic if statement that checks some arguments to see if a user can add another user as a friend. Well I had gotten that part down and for the longest time other people on my website have been able to use the feature. Now all of a sudden the if statement doesn't work? Why? Here is the statement: if ($privacy['privacy']['who_can_add'] == '1' AND $zext->user['id'] != '0' AND $zext->user['id'] != $u['id']) { $add_friend = $u['add_friend']; } of course if I put $add_friend outside the if statement, the button appears. How can a statment work one day but not the other? Is it an issue with my server? dump of $privacy: Code: [Select] $ => Array (4) ( | ['hide_o_status'] = Integer(1) 0 | ['who_can_view'] = Integer(1) 1 | ['who_can_add'] = Integer(1) 1 | ['who_can_contact'] = Integer(1) 1 ) dump of $zext->user['id']: Code: [Select] $ = String(2) "10" dump of $u['id']: Code: [Select] $ = String(2) "4" it all has correct information and the if statement has not been changed from before when it had worked and outputted $add_friend all day long. it worked until last night, i don't know what happened or why, php version has not been changed or anything. if anybody has any ideas on what's going on help would be much appreciated. Thanks, Matt. Hi I am a php learner and I am having some problems while loading images from templates. I will explain everything so hope you can understand my question.. My Folder Structure WEB SITE NAME - index.php [default landing page] + Images [images folder] + css [css folder] + templates [templates folder] |-- header.inc.php [header template] |-- footer.inc.php [footer template] + includes [folder for all classes and variables] + js [folder for all js files] + contact-us [this is a folder] |--index.php [this is the file inside the contact-us folder] + about-us [this is a folder] |-- index.php [this is the file inside the about-us folder] This is the header.inc.php file without some html markups Quote <title>Web Site Name</title> <link href="css/reset.css" rel="stylesheet" type="text/css" /> <link href="css/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script> </head> <body> <img src="images/phpmadeeasy.jpg" width="200" height="70" alt="php made easy logo" /> </body> ------------------------------------------------------------------------------ This is a sample main landing index.php page [i added codes only where i get into problems] Quote <?php include_once('includes/header.inc.php') ?> <div id="mainWrapper"> <img src="images/phpbigbanner.jpg" width="200" height="70" alt="php big banner" /> </div> <?php include_once('includes/footer.inc.php') ?> ------------------------------------------------------------------------------ As you can guess, default index.php file works fine... load both logo and banner images but... this is the index.php file located under the about-us folder Quote <?php include_once('includes/header.inc.php') ?> <div id="mainWrapper"> <img src="../images/phpbigbanner.jpg" width="200" height="70" alt="php big banner" /> </div> <?php include_once('includes/footer.inc.php') ?> ------------------------------------------------------------------------------ Here only the banner image load because the template file still show the logo image path as "images/phpmadeeasy.jpg" instead of "../images/phpmadeeasy.jpg" so is there any way me to define the default image folder as a variable so i can use that variable to load images from any directory level Example: Quote <?php echo $images; ?>images/phpmadeeasy.jpg" <script type="text/javascript" src="<?php echo $js; ?>/jquery-1.4.4.min.js" <link href="<?php echo $css; ?>reset.css" rel="stylesheet" type="text/css" Thanks........... If I have a web page located he www . company . com / how-to-repair-your-computer.html
And I decide to re-structure my website like this www . company . com / articles / how-to-repair-your-computer.html
How do I make sure that people don't search and end up at the old, now broken, link?
It seem inevitable that as a website grows, that you will want to re-organize things. What is the best way to make sure that anyone who searches or clicks on an old link - say from an email from a friend - doesn't get a 404 error?
Also, how do you avoid ruining a web pages rank on Google after you move things? (I think if the URL changes, Google makes you start all over as far as getting listed on page-1 and all of that?
Is this something I have to hande on my end, or is it a Google issue, or something else?
Hi I am a php learner and I am having some problems while loading images from templates. I will explain everything so hope you can understand my question.. My Folder Structure WEB SITE NAME - index.php [default landing page] + Images [images folder] + css [css folder] + templates [templates folder] |-- header.inc.php [header template] |-- footer.inc.php [footer template] + includes [folder for all classes and variables] + js [folder for all js files] + contact-us [this is a folder] |--index.php [this is the file inside the contact-us folder] + about-us [this is a folder] |-- index.php [this is the file inside the about-us folder] This is the header.inc.php file [just a example to let you understand my problem] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "URL/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="URL/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Web Site Name</title> <link href="css/reset.css" rel="stylesheet" type="text/css" /> <link href="css/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script> </head> <body> <img src="images/phpmadeeasy.jpg" width="200" height="70" alt="php made easy logo" /> </body> ------------------------------------------------------------------------------ This is a sample main landing index.php page [i added codes only where i get into problems] <?php include_once('includes/header.inc.php') ?> <div id="mainWrapper"> <img src="images/phpbigbanner.jpg" width="200" height="70" alt="php big banner" /> </div> <?php include_once('includes/footer.inc.php') ?> ------------------------------------------------------------------------------ As you can guess, default index.php file works fine... load both logo and banner images but... this is the index.php file located under the about-us folder <?php include_once('includes/header.inc.php') ?> <div id="mainWrapper"> <img src="../images/phpbigbanner.jpg" width="200" height="70" alt="php big banner" /> </div> <?php include_once('includes/footer.inc.php') ?> ------------------------------------------------------------------------------ Here only the banner image load because the template file still show the logo image path as "images/phpmadeeasy.jpg" instead of "../images/phpmadeeasy.jpg" so is there any way me to define the default image folder as a variable so i can use that variable to load images from any directory level Example: <?php echo $images; ?>images/phpmadeeasy.jpg" <script type="text/javascript" src="<?php echo $js; ?>/jquery-1.4.4.min.js" <link href="<?php echo $css; ?>reset.css" rel="stylesheet" type="text/css" Thanks........... I recently changed hosts, now my image uploader which used to work fine doesn't work. $indeximage = $_FILES['indeximage']; if($indeximage) { $indeximagename = basename($_FILES['indeximage']['name']); $indeximagenew = $_SERVER['DOCUMENT_ROOT'] . '/images/uploaded/index/' . $indeximagename; if (!file_exists($indeximagenew)) { if ((move_uploaded_file($_FILES['indeximage']['tmp_name'], $indeximagenew)) === true) { echo 'Index Image uploaded to this address '; echo 'http://www.address.co.uk/images/uploaded/index/'; echo $indeximagename; echo '<br />'; }else { echo 'Unable to move Index Image into the right folder.'; } } } It now echos Unable to move Index Image into the right folder. I tried putting: ini_set("display_errors", "1"); error_reporting(E_ALL); at the beginning. Before the upload it reads: Notice: Undefined index: images in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 58 Notice: Undefined index: indeximage in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 62 After it reads: Warning: move_uploaded_file(): Unable to move '/tmp/phpTd67fh' to '/var/www/vhosts/huhmagazine.co.uk/httpdocs/images/uploaded/index/calidewitt.jpg' in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 71 Ok mixing javascript with php.... im having bugs . I basically want to replace any broken image links with a picture "noimage.gif" in the images folder. I tried this code but am getting the error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/wormste1/public_html/tilburywebdesign/shop/FTPServers/barryottley/showroom.php on line 78 This is the javascript header - all seems fine: <script language="JavaScript" type="text/javascript"> function ImgError(source){ source.src = "/images/noimage.gif"; source.onerror = ""; return true; } </script> this is the code thats erroring... is it the way ive written in the code into the IMG tag? while($row = mysql_fetch_array($result)){ echo "<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=100% BORDER=0>"; echo "<TR />"; echo "<TD WIDTH=30% VALIGN=TOP />"; echo " <A HREF='images/".$row['photo']."' target=_blank><IMG SRC='images/".$row['photo']."' width=186 height=155 border=0 onerror="ImgError(this);" /></A> "; echo "<br />"; echo "</TD>"; echo "<TD WIDTH=10 VALIGN=TOP />"; $compQ = "SELECT companies.companyid, companies.companyname, companies.companylogo, companies.companyoccupation, companies.industry, eQuestions.capitalrequested FROM companies LEFT JOIN eQuestions ON companies.companyid = eQuestions.companyid"; This is not displaying data correctly. I'm assuming eQuestions.capitalrequested is not in the correct spot? I'm very out of practice, and trying to figure out old broken code. From a previous search page, results are pulled from the database, and the variables are passed. At first it works, but then, when I click on the pagination links to see the next page of results, it stops working. The next page appears with no info. Here's the code, I think it has something to do with the passed variables toward the bottom of the code, but I can't figure out what to do. <code> <?php require ('databaseconnection'); $display = 2; // it's intentionally only 2 for the moment to test pagination if (isset($_GET['np'])) { $num_pages = $_GET['np']; } else { $data = "SELECT COUNT(*), `descriptors`.*, `plantae`.* FROM `descriptors` LEFT JOIN `plantae` ON (`descriptors`.`plant_id` = `plantae`.`plant_name`) WHERE `leaf_shape` LIKE '%$s1%' AND `leaf_venation` LIKE '%$s3%' AND `leaf_margin` LIKE '%$s4%'"; $result = mysql_query ($data); if (!$result) { die("Oops, my query failed. The query is: <br>$data<br>The error is:<br>".mysql_error()); } $row = mysql_fetch_array($result, MYSQL_NUM); //row 40 above seems to be where a problem is $num_records = $row[0]; if ($num_records > $display) { $num_pages = ceil ($num_records/$display); } else { $num_pages = 1; } } if (isset($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } if(isset($_GET[submitted])) { // Now collect all info into $item variable $shape = $_GET['s1']; $color = $_GET['s2']; $vein = $_GET['s3']; $margin = $_GET['s4']; // This will take all info from database where row tutorial is $item and collects it into $data variable $data = mysql_query("SELECT `descriptors`.* ,`plantae`.* FROM `descriptors` LEFT JOIN `plantae` ON (`descriptors`.`plant_id` = `plantae`.`plant_name`) WHERE `leaf_shape` LIKE '%$s1%' AND `leaf_venation` LIKE '%$s3%' AND 'leaf_margin' LIKE '%$s4%' ORDER BY `plantae`.`scientific_name` ASC LIMIT $start, $display"); //chs added this in... echo '<table align="center" cellspacing="0" cellpading-"5"> <tr> <td align="left"><b></b></td> <td align="left"><b></b></td> <td align="left"><b>Leaf margin</b></td> <td align="left"><b>Leaf venation</b></td> </tr> '; while($row = mysql_fetch_array($data)){ echo '<tr> <td align="left"> <a href="view_plant.php?id=' . $row['plant_name'] . '">View plant</a> </td> <td align="left"> </td> <td align="left">' . $row['scientific_name'] . '</td> <td align="left">' . $row['common_name'] . '</td> <td align="left">' . $row['leaf_shape'] . '</td> </tr>'; } echo '</table>'; } if ($num_pages > 1) { echo '<br /><p>'; $current_page = ($start/$display) + 1; if ($current_page != 1) { echo '<a href="leafsearch4c.php?s=' . ($start - $display) . '&np=;' . $num_pages . '&s1=' . $s1 . '&s2=' . $s2 . '&s3=' . $s3 . '&s4=' . $s4 . '">Previous</a> '; } for ($i = 1; $i <= $num_pages; $i++) { if($i != $current_page) { echo '<a href="leafsearch4c.php?s=' . (($display * ($i - 1))) . '$np=' . $num_pages . '&s1=' . $s1 . '&s2=' . $s2 . '&s3=' . $s3 . '&s4=' . $s4 .'">' . $i . '</a>'; } else { echo $i . ' '; } } if ($current_page != $num_pages) { echo '<a href="leafsearch4c.php?s=' . ($start + $display) . '$np=' . $num_pages . '&s1=' . $s1 . '&s2=' . $s2 . '&s3=' . $s3 . '&s4=' . $s4 .'"> Next</a>'; } } //added curly ?></code> OK, hello everyone from your newest newbie - to this forum anyway. First thing to say is I do not claim to be the best php coder there is - as you will see when you look at my code ! Secondly, I have scoured/googled many sources to try and understand an answer to my problem without success. So, please first look at this page - http://www.thepearsons-ws.co.uk/php/MetMonthly.php If you pick March 2011 say you see a list of data presented on the same page. This is the effect I want to get to with a GD graph. If you now try my first attempt - http://www.thepearsons-ws.co.uk/php/raingraph3monthlyselect.php - and pick March 2011 and Submit AND click the link you get a graph on a new page. OK, but now what I want - I want the image on that same first page. So, I have the attached code which produces this - http://www.thepearsons-ws.co.uk/php/raingraph3monthlyselect2.php I have hacked the code around a bit but basically it's - PHP - form and data selection HTML - form with pull downs PHP - display graph. The image is broken. If I remove the HTML block completely it produces output but of course I can not vary the selection. Any small element of HTML here destroys the image - no whitespace or such - just <html> is enough. So, any clues on how to correctly structure this code would be greatly appreciated. Regards Phil [ m ]printf[/ m]produces a link to
php.net/<span>printf
Unless you use nobbc tags, then it works fine ???
Edited by Barand, 24 November 2014 - 02:25 PM. Hey People, Im stuck right now and I need some fresh eyes. Seems this functions someone made that I gotta fix is broken Im assuming maybe a missing bracket or one out of place.. but.. Im not seeing it, ive been staring at it for far to long tryin to fix it find the issue etc.. and its eluding me. Right now the error I am getting is "unexpected $end" heres the function Code: [Select] function getlinkedinstoredContacts($user_id,$limit=10,$offset=1){ $query = $this->db->get_where('cm_user_linkedin_contacts', array('user_id' => $user_id,'same_company'=>'Y'),$limit,$offset); if ($query->num_rows() > 0){ $contacts = $query->result(); //Loop throught the contact list foreach ($contacts as $key => $contact){ $headline = $contact->headline; if (preg_match('/(at )| @ /', $headline)){$arr = preg_split('/(at )| @ /', $headline, 2);} elseif (preg_match('/,/', $headline)){$arr = preg_split('/,/', $headline, 2);} else{$arr[0] = $headline;$arr[1] = '';} $arr[0] = preg_replace('/^\s*/', '', $arr[0]); $arr[0] = preg_replace('/\s*$/', '', $arr[0]); $arr[1] = preg_replace('/^\s*/', '', $arr[1]); $arr[1] = preg_replace('/\s*$/', '', $arr[1]); $current_company_position = $arr[0]; // job_title $current_company_name=$arr[1]; //company //for testing if ($counter > 21){unset($contacts[$key]);} else{ $contact->job_title=$current_company_position; $contact->current_company=$current_company_name; if ($contact->picture_url == ''){ $contact->picture_url = $this->config->item('base_url') . "static/images/avatar-large.jpg')"; $contacts[$key]=$contact; $counter++; } } return $contacts; } return null; } I have 2 pages in my flash site that call some PHP files. The pages are a feedback page and a locator page. When my server went from PHP4 to PHP5 both pages stopped displaying the content. When I load the flash pages with Fiddler open, fiddler shows a 500 error on the PHP files that the flash is calling. I'm certain my database connections are good, file paths have not changed since the server maintenance, and I have .htaccess files except they are blank. Can anyone advise what I can do to find where the problem is? I have the PHP code below that showed the 500 errors. Any help would be really appreciated. This is the locator page: Code: [Select] <?php include_once('db_connect.inc.php'); $query = "SELECT state FROM stores group BY state ORDER BY state"; $result = mysql_query($query); if(mysql_num_rows($result)==NULL){ $r_string = '&error=1&msg=No Records Found.'; }else{ $r_string = '&error=0&n='.mysql_num_rows($result) . '&r_states='; $i = 0; $r=''; while ($row = mysql_fetch_assoc($result)) { if($r!='') $r .= '||'; $r .= $row['state']; $i++; } $r_string .= $r; // add extra & to prevent returning extra chars at the end $r_string .='&'; } echo $r_string; ?> This is the feedback page: Code: [Select] <?php include_once('inc/feedbackconn.inc.php'); echo '&rsult='; $query = "SELECT * FROM messages where active!=0"; $result = mysql_query($query); $num = @mysql_num_rows($result); $cfeed=$_POST['sFeed']; $cfeed--; $query = "SELECT * FROM messages where active='1' ORDER BY id LIMIT " . $cfeed . ',1'; $result = mysql_query($query); //$row = mysql_fetch_array($result); if($num==NULL){ echo "No Records."; exit(); } while($row = @mysql_fetch_array($result)){ $b_name = stripslashes($row[strName]); $b_loc = stripslashes($row[strLocation]); $b_mes = stripslashes($row[strMessage]); $b_id = $row[id]; $b_active = $row[active]; $feedArray[] = array("name"=>$b_name,"location"=>$b_loc,"feedback"=>$b_mes,"id"=>$b_id,"active"=>$b_active); } /* /////////////// DISPLAY THE RECORDS ///////////////// */ $numOfMessages = sizeOf($feedArray); for($i=0;$i<$numOfMessages;$i++){ //------------------------------------------------------------------ //echo $feedArray[$i]['id']."<br>\n"; echo '<b><i>' . $feedArray[$i]['feedback']."</i><br><br>"; echo $feedArray[$i]['name']."<br>"; echo $feedArray[$i]['location']."</b>"; //--------------------------------------------------------------------- } echo '&tFeeds=' . $num; echo '&cFeed=' . $_POST['sFeed']; ?> |