Jump to content

blui

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

blui's Achievements

Member

Member (2/5)

0

Reputation

  1. lumio, I tried as you suggested, but unfortunately it did not work, thanks anyway. However I seem to have stumbled along and got a step closer, now if your login details are correct, you are redirected but not to the page you originally requested, but back to the root folder (showing the files within the directory) or the index.html of the root if there is one there. Again, I'm open to suggestions, my code is belwo:- <?php session_start(); ob_start(); session_register('logged'); $_SESSION['logged'] = 0; ?> <? $redirect = isset($_POST['redirect']); if (isset($_POST['submit'])) { if ($_POST['username'] == "Paul" && $_POST['password'] == "daleragu") { $redirect = $_POST['redirect']; $_SESSION['logged'] = 1; header ("Location: $redirect"); } else { ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> <input type="submit" name="submit" value="Login"> </form>got it wrong did we </table> <? } } else { ?> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> <input type="submit" name="submit" value="Login"> </form> </table> <? } ?>
  2. I have stripped the code to the bones only php and a small amount of html, I didn't realise when I copied and pasted how big it was, sorry. Anyway the revised code is below:- [ CODE ] <?php session_start(); ob_start(); session_register('logged'); // add single quotes to avoid the constant stuff. $_SESSION['logged'] = 0; ?> <? $redirect = isset($_POST['redirect'])?$_POST['redirect']:null; if (isset($_POST['submit'])) { if ($_POST['username'] == "Paul" && $_POST['password'] == "daleragu") { $redirect = $_POST['redirect']; $_SESSION['logged'] = 1; header ("Location: $redirect"); } else { ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> <input type="submit" name="submit" value="Login"> </form> </table> <? } } else { ?> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> <input type="submit" name="submit" value="Login"> </form> </table> <? } ?>
  3. Hi, I have a login script that is designed so should someone try and bypass the login screen you are redirected back to it (that parts fine) on entering the correct username and password and submmitted you should be sent back to your originally requested page, but it just refreshes the same page with no content. Any advice would be greatly welcome, Thanks blui so try and go to - http://www.scarboroughwebsitedesign.com/watertonpark/addphoto.php you should be redirected to here - http://www.scarboroughwebsitedesign.com/watertonpark/adminloginstart.php The username is Paul The password is daleragu the code is here - <?php session_start(); ob_start(); session_register('logged'); // add single quotes to avoid the constant stuff. $_SESSION['logged'] = 0; ?> <? $redirect = isset($_POST['redirect'])?$_POST['redirect']:null; // added a check here to avoid the index error. also changed to POST. if (isset($_POST['submit'])) { if ($_POST['username'] == "Paul" && $_POST['password'] == "daleragu")// replace this logic with authorization from mysql if needed {//if it gets to this point, the authorization is correct, the we can redirect with the header 3 lines down $redirect = $_POST['redirect']; $_SESSION['logged'] = 1; header ("Location: $redirect"); } else { ?> <html> <head> <title>Upload Image Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- ImageReady Preload Script (paul1.psd) --> <script type="text/javascript"> <!-- function newImage(arg) { if (document.images) { rslt = new Image(); rslt.src = arg; return rslt; } } function changeImages() { if (document.images && (preloadFlag == true)) { for (var i=0; i<changeImages.arguments.length; i+=2) { document[changeImages.arguments].src = changeImages.arguments[i+1]; } } } var preloadFlag = false; function preloadImages() { if (document.images) { accommodation_over = newImage("images/accommodation-over.gif"); conference_over = newImage("images/conference-over.gif"); golf_over = newImage("images/golf-over.gif"); weddings_over = newImage("images/weddings-over.gif"); christmas_over = newImage("images/christmas-over.gif"); leisure_over = newImage("images/leisure-over.gif"); restaurant_over = newImage("images/restaurant-over.gif"); special_over = newImage("images/special-over.gif"); contact_over = newImage("images/contact-over.gif"); preloadFlag = true; } } // --> </script> <!-- End Preload Script --> <style type="text/css"> <!-- body { background-color: #c3bda3; } .h1 { font-family: Verdana; font-size: 14px; font-weight: bold; } .bodytext { font-family: Verdana; font-size: 10px; } .h2 { font-family: Verdana; color: #FFFFFF; } .style3 {color: #F2EFE4} .style5 { color: #F2EFE4; font-family: Verdana; font-size: 11px; } --> </style></head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="preloadImages();"> <!-- ImageReady Slices (paul1.psd) --> <table width="864" height="560" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01"> <tr> <td width="7" rowspan="3" background="images/paul1_01.gif"> </td> <td colspan="9"> <img src="images/header.gif" width="850" height="115" alt=""></td> <td width="7" rowspan="3" background="images/paul1_03.gif"> </td> </tr> <tr> <td> <a href="#" onmouseover="changeImages('accommodation', 'images/accommodation-over.gif'); return true;" onmouseout="changeImages('accommodation', 'images/accommodation.gif'); return true;" onmousedown="changeImages('accommodation', 'images/accommodation-over.gif'); return true;" onmouseup="changeImages('accommodation', 'images/accommodation-over.gif'); return true;"> <img name="accommodation" src="images/accommodation.gif" width="157" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('conference', 'images/conference-over.gif'); return true;" onmouseout="changeImages('conference', 'images/conference.gif'); return true;" onmousedown="changeImages('conference', 'images/conference-over.gif'); return true;" onmouseup="changeImages('conference', 'images/conference-over.gif'); return true;"> <img name="conference" src="images/conference.gif" width="118" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('golf', 'images/golf-over.gif'); return true;" onmouseout="changeImages('golf', 'images/golf.gif'); return true;" onmousedown="changeImages('golf', 'images/golf-over.gif'); return true;" onmouseup="changeImages('golf', 'images/golf-over.gif'); return true;"> <img name="golf" src="images/golf.gif" width="83" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('weddings', 'images/weddings-over.gif'); return true;" onmouseout="changeImages('weddings', 'images/weddings.gif'); return true;" onmousedown="changeImages('weddings', 'images/weddings-over.gif'); return true;" onmouseup="changeImages('weddings', 'images/weddings-over.gif'); return true;"> <img name="weddings" src="images/weddings.gif" width="61" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('christmas', 'images/christmas-over.gif'); return true;" onmouseout="changeImages('christmas', 'images/christmas.gif'); return true;" onmousedown="changeImages('christmas', 'images/christmas-over.gif'); return true;" onmouseup="changeImages('christmas', 'images/christmas-over.gif'); return true;"> <img name="christmas" src="images/christmas.gif" width="64" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('leisure', 'images/leisure-over.gif'); return true;" onmouseout="changeImages('leisure', 'images/leisure.gif'); return true;" onmousedown="changeImages('leisure', 'images/leisure-over.gif'); return true;" onmouseup="changeImages('leisure', 'images/leisure-over.gif'); return true;"> <img name="leisure" src="images/leisure.gif" width="98" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('restaurant', 'images/restaurant-over.gif'); return true;" onmouseout="changeImages('restaurant', 'images/restaurant.gif'); return true;" onmousedown="changeImages('restaurant', 'images/restaurant-over.gif'); return true;" onmouseup="changeImages('restaurant', 'images/restaurant-over.gif'); return true;"> <img name="restaurant" src="images/restaurant.gif" width="71" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('special', 'images/special-over.gif'); return true;" onmouseout="changeImages('special', 'images/special.gif'); return true;" onmousedown="changeImages('special', 'images/special-over.gif'); return true;" onmouseup="changeImages('special', 'images/special-over.gif'); return true;"> <img name="special" src="images/special.gif" width="83" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('contact', 'images/contact-over.gif'); return true;" onmouseout="changeImages('contact', 'images/contact.gif'); return true;" onmousedown="changeImages('contact', 'images/contact-over.gif'); return true;" onmouseup="changeImages('contact', 'images/contact-over.gif'); return true;"> <img name="contact" src="images/contact.gif" width="115" height="22" border="0" alt=""></a></td> </tr> <tr> <td height="423" colspan="9" align="center" valign="middle" bgcolor="#F2EFE4"><table width="850" height="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="180" align="center"><table id="Table_01" width="160" height="403" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="250"><img src="images/index1.gif" width="160" height="250" alt="1"></td> </tr> <tr bgcolor="#F2EFE4"> <td height="5"><img src="images/background.jpg" width="1" height="1" alt="1"></td> </tr> <tr class="h2"> <td height="25" bgcolor="#524535"><span class="style3">Check Availability </span></td> </tr> <tr bgcolor="#F2EFE4"> <td height="5"><img src="images/background.jpg" width="1" height="1" alt="1"></td> </tr> <tr class="h2"> <td height="25" bgcolor="#8C6E50">Virtual Tour </td> </tr> <tr bgcolor="#F2EFE4"> <td height="5"><img src="images/background.jpg" width="1" height="1" alt="1"></td> </tr> <tr class="h2"> <td height="25" bgcolor="#A88D6F">Guy Fawkes York </td> </tr> <tr> <td height="5"><img src="images/background.jpg" width="1" height="1" alt="1"></td> </tr> <tr> <td><img src="images/indexthumbs.gif" width="160" height="65" alt="1"></td> </tr> </table></td> <td><table width="670" height="409" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" align="left" valign="top" class="h1">Admin Login Area</td> </tr> <tr> <td height="389" align="left" valign="top" class="bodytext"><p><table width="250" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> <input type="submit" name="submit" value="Login"> </form> </table><br> </td> <td width="180" height="389" align="center" valign="top"><br> <img src="images/heli.jpg" alt="" width="160" height="120"><br> <br> <img src="images/heli.jpg"></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td background="images/paul1_01.gif"> </td> <td colspan="9" align="center" valign="middle" bgcolor="#524535"><span class="style5">Best Western Waterton Park Hotel, Walton Hall, Walton, Wakefield, West Yorkshire, WF2 6PW, Telephone 01924 257911</span></td> <td background="images/paul1_03.gif"> </td> </tr> </table> <!-- End ImageReady Slices --> <? } } else { ?> <html> <head> <title>Upload Image Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- ImageReady Preload Script (paul1.psd) --> <script type="text/javascript"> <!-- function newImage(arg) { if (document.images) { rslt = new Image(); rslt.src = arg; return rslt; } } function changeImages() { if (document.images && (preloadFlag == true)) { for (var i=0; i<changeImages.arguments.length; i+=2) { document[changeImages.arguments].src = changeImages.arguments[i+1]; } } } var preloadFlag = false; function preloadImages() { if (document.images) { accommodation_over = newImage("images/accommodation-over.gif"); conference_over = newImage("images/conference-over.gif"); golf_over = newImage("images/golf-over.gif"); weddings_over = newImage("images/weddings-over.gif"); christmas_over = newImage("images/christmas-over.gif"); leisure_over = newImage("images/leisure-over.gif"); restaurant_over = newImage("images/restaurant-over.gif"); special_over = newImage("images/special-over.gif"); contact_over = newImage("images/contact-over.gif"); preloadFlag = true; } } // --> </script> <!-- End Preload Script --> <style type="text/css"> <!-- body { background-color: #c3bda3; } .h1 { font-family: Verdana; font-size: 14px; font-weight: bold; } .bodytext { font-family: Verdana; font-size: 10px; } .h2 { font-family: Verdana; color: #FFFFFF; } .style3 {color: #F2EFE4} .style5 { color: #F2EFE4; font-family: Verdana; font-size: 11px; } --> </style></head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="preloadImages();"> <!-- ImageReady Slices (paul1.psd) --> <table width="864" height="560" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01"> <tr> <td width="7" rowspan="3" background="images/paul1_01.gif"> </td> <td colspan="9"> <img src="images/header.gif" width="850" height="115" alt=""></td> <td width="7" rowspan="3" background="images/paul1_03.gif"> </td> </tr> <tr> <td> <a href="#" onmouseover="changeImages('accommodation', 'images/accommodation-over.gif'); return true;" onmouseout="changeImages('accommodation', 'images/accommodation.gif'); return true;" onmousedown="changeImages('accommodation', 'images/accommodation-over.gif'); return true;" onmouseup="changeImages('accommodation', 'images/accommodation-over.gif'); return true;"> <img name="accommodation" src="images/accommodation.gif" width="157" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('conference', 'images/conference-over.gif'); return true;" onmouseout="changeImages('conference', 'images/conference.gif'); return true;" onmousedown="changeImages('conference', 'images/conference-over.gif'); return true;" onmouseup="changeImages('conference', 'images/conference-over.gif'); return true;"> <img name="conference" src="images/conference.gif" width="118" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('golf', 'images/golf-over.gif'); return true;" onmouseout="changeImages('golf', 'images/golf.gif'); return true;" onmousedown="changeImages('golf', 'images/golf-over.gif'); return true;" onmouseup="changeImages('golf', 'images/golf-over.gif'); return true;"> <img name="golf" src="images/golf.gif" width="83" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('weddings', 'images/weddings-over.gif'); return true;" onmouseout="changeImages('weddings', 'images/weddings.gif'); return true;" onmousedown="changeImages('weddings', 'images/weddings-over.gif'); return true;" onmouseup="changeImages('weddings', 'images/weddings-over.gif'); return true;"> <img name="weddings" src="images/weddings.gif" width="61" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('christmas', 'images/christmas-over.gif'); return true;" onmouseout="changeImages('christmas', 'images/christmas.gif'); return true;" onmousedown="changeImages('christmas', 'images/christmas-over.gif'); return true;" onmouseup="changeImages('christmas', 'images/christmas-over.gif'); return true;"> <img name="christmas" src="images/christmas.gif" width="64" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('leisure', 'images/leisure-over.gif'); return true;" onmouseout="changeImages('leisure', 'images/leisure.gif'); return true;" onmousedown="changeImages('leisure', 'images/leisure-over.gif'); return true;" onmouseup="changeImages('leisure', 'images/leisure-over.gif'); return true;"> <img name="leisure" src="images/leisure.gif" width="98" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('restaurant', 'images/restaurant-over.gif'); return true;" onmouseout="changeImages('restaurant', 'images/restaurant.gif'); return true;" onmousedown="changeImages('restaurant', 'images/restaurant-over.gif'); return true;" onmouseup="changeImages('restaurant', 'images/restaurant-over.gif'); return true;"> <img name="restaurant" src="images/restaurant.gif" width="71" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('special', 'images/special-over.gif'); return true;" onmouseout="changeImages('special', 'images/special.gif'); return true;" onmousedown="changeImages('special', 'images/special-over.gif'); return true;" onmouseup="changeImages('special', 'images/special-over.gif'); return true;"> <img name="special" src="images/special.gif" width="83" height="22" border="0" alt=""></a></td> <td> <a href="#" onmouseover="changeImages('contact', 'images/contact-over.gif'); return true;" onmouseout="changeImages('contact', 'images/contact.gif'); return true;" onmousedown="changeImages('contact', 'images/contact-over.gif'); return true;" onmouseup="changeImages('contact', 'images/contact-over.gif'); return true;"> <img name="contact" src="images/contact.gif" width="115" height="22" border="0" alt=""></a></td> </tr> <tr> <td height="423" colspan="9" align="center" valign="middle" bgcolor="#F2EFE4"><table width="850" height="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="180" align="center"><table id="Table_01" width="160" height="403" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="250"><img src="images/index1.gif" width="160" height="250" alt="1"></td> </tr> <tr bgcolor="#F2EFE4"> <td height="5"><img src="images/background.jpg" width="1" height="1" alt="1"></td> </tr> <tr class="h2"> <td height="25" bgcolor="#524535"><span class="style3">Check Availability </span></td> </tr> <tr bgcolor="#F2EFE4"> <td height="5"><img src="images/background.jpg" width="1" height="1" alt="1"></td> </tr> <tr class="h2"> <td height="25" bgcolor="#8C6E50">Virtual Tour </td> </tr> <tr bgcolor="#F2EFE4"> <td height="5"><img src="images/background.jpg" width="1" height="1" alt="1"></td> </tr> <tr class="h2"> <td height="25" bgcolor="#A88D6F">Guy Fawkes York </td> </tr> <tr> <td height="5"><img src="images/background.jpg" width="1" height="1" alt="1"></td> </tr> <tr> <td><img src="images/indexthumbs.gif" width="160" height="65" alt="1"></td> </tr> </table></td> <td><table width="670" height="409" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" align="left" valign="top" class="h1">Admin Login Area</td> </tr> <tr> <td height="389" align="left" valign="top" class="bodytext"><p><table width="250" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> <input type="submit" name="submit" value="Login"> </form> </table><br> </td> <td width="180" height="389" align="center" valign="top"><br> <img src="images/heli.jpg" alt="" width="160" height="120"><br> <br> <img src="images/heli.jpg"></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td background="images/paul1_01.gif"> </td> <td colspan="9" align="center" valign="middle" bgcolor="#524535"><span class="style5">Best Western Waterton Park Hotel, Walton Hall, Walton, Wakefield, West Yorkshire, WF2 6PW, Telephone 01924 257911</span></td> <td background="images/paul1_03.gif"> </td> </tr> </table> <!-- End ImageReady Slices --> <? } ?>
  4. If the general concensus is that a noobie could not do it, any idea on how much would it cost for a proper php programmer to do?
  5. Hi all, I have a client who wants something like this, its a customisation for creating your own jewellery:- http://www.diamonds.com/CYO/cyo_ring.aspx Can you please provide me with ideas, thoughts, comments on how difficult this is, as I still class myself as a bit of a noobie when it comes to php, I suppose what I am really saying is would a noobie with a few hours spare be able to do it or at least something close. If you can think of any method of making it easier that would also be welcome. All input greatly appreciated. Thanks blu
  6. Hi all, I have an admin area which works using sessions, should someone try and go directly to a specific page (e.g. postinfo.php) in the admin area the code should redirect them to the login page (adminloginstart.php) , if the username and password they enter are correct the login page should then redirect them to the original page they requested. The code works fine apart from not redirecting the valid user back to the original requested URL all off the codes in question are listed below, can anyone please help? postinfo.php:- <? require_once('watertonloginc.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"> <? require_once('connectionlocal.php'); ?> ------------------------------------------------------------ watertonloginc.php:- <? session_start(); if ($_SESSION['logged'] != 1) { $redirect = $_SERVER['PHP_SELF']; header("Location: adminloginstart.php?redirect=$redirect"); } ?> ------------------------------------------------------------- adminloginstart.php:- <?php session_start(); ob_start(); session_register('logged'); // add single quotes to avoid the constant stuff. $_SESSION['logged'] = 0; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <? $redirect = isset($_POST['redirect'])?$_POST['redirect']:null; // added a check here to avoid the index error. also changed to POST. if (isset($_POST['submit'])) { if ($_POST['username'] == "Paul" && $_POST['password'] == "daleragu")// replace this logic with authorization from mysql if needed {//if it gets to this point, the authorization is correct, the we can redirect with the header 3 lines down $redirect = $_POST['redirect']; $_SESSION['logged'] = 1; header ("Location: $redirect"); } else { ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" name="submit" value="Login"> </form> </table> <? } } else { ?> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" name="submit" value="Login"> </form> </table> <? } ?>
  7. Thanks all that seems to be working fine now, cheers greatly appreciated.
  8. Thanks JayLewis, I tried your code and still recieved the following error messages any idea why? Notice: Use of undefined constant logged - assumed 'logged' in f:\program files\easyphp1-7\www\php\adminloginstart.php on line 4 Notice: Undefined index: redirect in f:\program files\easyphp1-7\www\php\adminloginstart.php on line 9
  9. how and where would I use the [*code][*/code] tags any clarification would be a great help, Thanks blu
  10. Hi all, I have a php login script that used to work fine but now it appears to not working correctly - I am assuming its down to the register_globals being now off. Can some please tell me what i need to do to get ths script working again please? <? session_start(); ob_start(); session_register(logged); $_SESSION['logged'] = 0; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <? $redirect = $_GET['redirect']; if (isset($_POST['submit'])) { if ($_POST['username'] == "Paul" && $_POST['password'] == "daleragu")// replace this logic with authorization from mysql if needed {//if it gets to this point, the authorization is correct, the we can redirect with the header 3 lines down $redirect = $_POST['redirect']; $_SESSION['logged'] = 1; header ("Location: $redirect"); } else { ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br><br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Login"> </form> </table> <? } } else { ?> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br><br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Login"> </form> </table> <? } ?> </body> </html>
  11. I am pretty new to php, but have more experience with html & Dreamweaver. This is just an idea but can't you use the onmousedown behaviour, if someone clicks on a link the onmousedown beaviour automatically inserts some text in to your text box - should also be completely do-able with standard HTML and maybe some basic Javascript. Suggest you look at the likes of www.dynamicdrive.com for ideas or pointers. I certainly dont think you need php for this, hope it helps
  12. Hi all, I am still getting used to php, but I have managed to create a very basic CMS, the CMS cover 6 pages and each page can have its title, pagetext, image link 1 and 2 altered. I have doen the best I can but, I imagine that the code I have produced is somewhat ugly and could be clearer and slimlined. I have included the code for both the form page and the post page. Any pointers, examples of how this code could be made more efficient, would be greatfully appreciated. Thanks blu postinfo.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"> <? require_once('connectionlocal.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="600" border="0" cellspacing="0" cellpadding="0"> <form action="../php/postinfo2.php" method="post"><tr> <td width="200">Special Offers Title </td> <td width="322"><input name="title1" type="text" value=" <?php // Get a specific result from the "example" table $result = mysql_query("SELECT * FROM cmscontent WHERE PRIMARYID='1'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['title']; ?> "/> </td> </tr> <tr> <td width="200">Special Offers Page Text </td> <td><textarea name="pagetext1" cols="50" rows="8"><?php echo $row['pagetext'];?></textarea></td> </tr> <tr> <td width="200">Special Offers Image 1</td> <td><select name="imagelist"><option value=<?php echo $row['links1'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200">Special Offers Image 2 </td> <td><select name="imagelist10"><option value=<?php echo $row['links1'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td width="200">Leisure Title </td> <td><input type="pagetext" name="title2" value=" <?php // Get a specific result from the "example" table $result = mysql_query("SELECT * FROM cmscontent WHERE PRIMARYID='2'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['title']; ?> "/></td> </tr> <tr> <td width="200">Leisure Page Text </td> <td><textarea name="pagetext2" cols="50" rows="8"><?php echo $row['pagetext'];?></textarea></td> </tr> <tr> <td width="200">Leisure Image 1 </td> <td><select name="imagelist2"><option value=<?php echo $row['links1'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200">Leisure Image 2 </td> <td><select name="imagelist12"><option value=<?php echo $row['links2'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td width="200">Golf Title </td> <td><input type="text" name="title3" value=" <?php // Get a specific result from the "example" table $result = mysql_query("SELECT * FROM cmscontent WHERE PRIMARYID='3'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['title']; ?> "/></td> </tr> <tr> <td width="200">Golf Page Text </td> <td><textarea name="pagetext3" cols="50" rows="8"><?php echo $row['pagetext'];?></textarea></td> </tr> <tr> <td width="200">Golf Image 1 </td> <td> <select name="imagelist3"><option value=<?php echo $row['links1'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200">Golf Image 2 </td> <td><select name="imagelist13"><option value=<?php echo $row['links2'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td width="200">Christmas Title </td> <td><input type="text" name="title4" value=" <?php // Get a specific result from the "example" table $result = mysql_query("SELECT * FROM cmscontent WHERE PRIMARYID='4'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['title']; ?> "/></td> </tr> <tr> <td width="200">Christmas Page Text </td> <td><textarea name="pagetext4" cols="50" rows="8"><?php echo $row['pagetext'];?></textarea></td> </tr> <tr> <td width="200">Christmas Image 1 </td> <td><select name="imagelist4"><option value=<?php echo $row['links1'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200">Christmas Image 2 </td> <td><select name="imagelist14"><option value=<?php echo $row['links2'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td width="200">Conferences Title </td> <td><input type="text" name="title5" value=" <?php // Get a specific result from the "example" table $result = mysql_query("SELECT * FROM cmscontent WHERE PRIMARYID='5'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['title']; ?> "/></td> </tr> <tr> <td width="200">Conferences Page Text </td> <td><textarea name="pagetext5" cols="50" rows="8"><?php echo $row['pagetext'];?></textarea></td> </tr> <tr> <td width="200">Conferences Image 1 </td> <td><select name="imagelist5"><option value=<?php echo $row['links1'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200">Conferences Image 2 </td> <td><select name="imagelist15"><option value=<?php echo $row['links2'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td width="200">Sample Menu Title </td> <td><input type="text" name="title6" value=" <?php // Get a specific result from the "example" table $result = mysql_query("SELECT * FROM cmscontent WHERE PRIMARYID='6'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['title']; ?> "/></td> </tr> <tr> <td width="200">Sample Menu Page Text </td> <td><textarea name="pagetext6" cols="50" rows="8"><?php echo $row['pagetext'];?></textarea></td> </tr> <tr> <td width="200">Sample Menu Image 1 </td> <td><select name="imagelist6"><option value=<?php echo $row['links1'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200">Sample Menu Image 2 </td> <td><select name="imagelist16"><option value=<?php echo $row['links2'];?> ></option> <? require('directorylistinginc.php'); ?> </select></td> </tr> <tr> <td width="200"> </td> <td> <input type="submit" name="submit" value="submit"> </td> </tr> </form></table> </body> </html> ----------------------------------------------------- directorylistinginc.php:- <? $file_dir="images/thumbs"; $dir=opendir($file_dir); while ($file=readdir($dir)) { if ($file != "." && $file != "..") { echo "<option value=".$file_dir."/".$file." >".$file.""; echo "</option>"; } } ?> -------------------------------------------------------------------- postinfo2.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"> <? require_once('connectionlocal.php'); ?> <?PHP //inserts title into approprate cell $sql = "UPDATE `cmscontent` SET `title` = '{$_POST['title1']}' WHERE `PRIMARYID`='1'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `title` = '{$_POST['title2']}' WHERE `PRIMARYID`='2'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `title` = '{$_POST['title3']}' WHERE `PRIMARYID`='3'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `title` = '{$_POST['title4']}' WHERE `PRIMARYID`='4'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `title` = '{$_POST['title5']}' WHERE `PRIMARYID`='5'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `title` = '{$_POST['title6']}' WHERE `PRIMARYID`='6'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); //inserts pagetext into approprate cell $sql = "UPDATE `cmscontent` SET `pagetext` = '{$_POST['pagetext1']}' WHERE `PRIMARYID`='1'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `pagetext` = '{$_POST['pagetext2']}' WHERE `PRIMARYID`='2'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `pagetext` = '{$_POST['pagetext3']}' WHERE `PRIMARYID`='3'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `pagetext` = '{$_POST['pagetext4']}' WHERE `PRIMARYID`='4'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `pagetext` = '{$_POST['pagetext5']}' WHERE `PRIMARYID`='5'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `pagetext` = '{$_POST['pagetext6']}' WHERE `PRIMARYID`='6'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); //inserts image link into approprate cell $sql = "UPDATE `cmscontent` SET `links1` = '{$_POST['imagelist']}' WHERE `PRIMARYID`='1'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links1` = '{$_POST['imagelist2']}' WHERE `PRIMARYID`='2'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links1` = '{$_POST['imagelist3']}' WHERE `PRIMARYID`='3'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links1` = '{$_POST['imagelist4']}' WHERE `PRIMARYID`='4'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links1` = '{$_POST['imagelist5']}' WHERE `PRIMARYID`='5'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links1` = '{$_POST['imagelist6']}' WHERE `PRIMARYID`='6'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links2` = '{$_POST['imagelist10']}' WHERE `PRIMARYID`='1'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links2` = '{$_POST['imagelist12']}' WHERE `PRIMARYID`='2'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links2` = '{$_POST['imagelist13']}' WHERE `PRIMARYID`='3'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links2` = '{$_POST['imagelist14']}' WHERE `PRIMARYID`='4'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links2` = '{$_POST['imagelist15']}' WHERE `PRIMARYID`='5'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); $sql = "UPDATE `cmscontent` SET `links2` = '{$_POST['imagelist16']}' WHERE `PRIMARYID`='6'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); ?> <?php // Change to the URL you want to redirect to $URL="http://pauldaleragu/php/postinfo.php"; header ("Location: $URL"); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html>
  13. I tried the code you entered but it produced no results - I have tried the following code, but it keeps returning a S as a result - it should be returning Special Offers <input name="title1" type="text" value=" <?php $sql = "SELECT title FROM cmscontent WHERE PRIMARYID='1'"; mysql_query($sql) || die("An error has happened: " . mysql_error()); echo $sql['title']; ?> " /> Any thoughts anyone?
  14. Hi I need to have the default / initial value of my form select the information already stored in the database field where the primaryid = 1 I have managed to create a recordset which collects all the data from the database as well as a echo script that prints the value out both of these are below (however I have not been able to figure out what i put in the code so that only a specific result is returned where the primaryid = 1 Any help would be greatly appreciated. recordset:- <?php mysql_select_db($database_localconnection, $localconnection); $query_Recordset1 = "SELECT * FROM cmscontent WHERE cmscontent.PRIMARYID"; $Recordset1 = mysql_query($query_Recordset1, $localconnection) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> ------------------------------------------- code that returns value:- <input name="title1" type="text" value="<?php echo $row_Recordset1['title']; ?>" /> I am assuming that the code needs to along the lines of:- <input name="title1" type="text" value="<?php echo $row_Recordset1['title'] WHERE PRIMARYID=1; ?>" />
  15. Thanks for your pointers - I now have it working correctly
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.