Jump to content

lbh2011

Members
  • Posts

    55
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

lbh2011's Achievements

Member

Member (2/5)

0

Reputation

  1. Does anyone else find that in Windows 8 / IE10 it is impossible to add a new line when writing a new post?
  2. What sort of website are you looking to adapt? You could use CSS to format the existing pages differently for mobile devices or find the user agent (browser type) using PHP and redirect the user to a separate mobile optimised page.
  3. DROP TABLE IF EXISTS `flights`; CREATE TABLE `flights` ( `flight_id` int(11) NOT NULL AUTO_INCREMENT, `flight_icon` int(11) NOT NULL, `flight_path` int(11) NOT NULL, `flight_from` int(11) NOT NULL, `flight_to` int(11) NOT NULL, PRIMARY KEY (`flight_id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
  4. Does this work for you? <?php $error_msg = ""; if ($_POST['username']) { $username = $_POST['username']; $password = $_POST['password']; // Simple hard coded values for the correct username and password $admin = "admin"; $adminpass = "admin"; // connect to mysql here if you store admin username and password in your database // This would be the prefered method of storing the values instead of hard coding them here into the script if (($username != $admin) || ($password != $adminpass)) { echo '<font color="#FF0000">Your login information is incorrect</font>'; echo '<h3>Only the administrator can view this page</h3><br /> <table width="340" border="0"> <form action="" method="post"> <tr> <td colspan="2">Please Log In Here</td> </tr> <tr> <td width="96">Username:</td> <td width="234"><input type="text" name="username" id="username" style="width:98%" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" id="password" style="width:98%" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="button" id="button" value="Log In Now" /></td> </tr> </form> </table> <br /> <br /> <br /> <a href="../">Or click here to head back to the homepage</a>'; exit; } else { session_register('admin'); $_SESSION['admin'] = $username; require_once "index.php"; }} else { echo '<h3>Only the administrator can view this page</h3><br /> <table width="340" border="0"> <form action="" method="post"> <tr> <td colspan="2">Please Log In Here</td> </tr> <tr> <td width="96">Username:</td> <td width="234"><input type="text" name="username" id="username" style="width:98%" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" id="password" style="width:98%" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="button" id="button" value="Log In Now" /></td> </tr> </form> </table> <br /> <br /> <br /> <a href="../">Or click here to head back to the homepage</a>'; } ?>
  5. Have you connected to the database?
  6. Does anyone have a preferred or recommended method of restricting access to a website depending on which country the visitor originates from? I would like to prevent users from accessing (or registering to access) the website from anywhere outside of the United Kingdom. I am aware of various .htaccess and php methods but am also aware that .htaccess methods for example can prevent Google from indexing the site correctly.
  7. Thanks Backslider. How about within $row though? <td><a href="update.php?id='.$id.'">Update</a></td> How would I apply this code to that? (So only display the update link when the user is logged in) <?php if($c->is_admin == 'Yes') { // do stuff } else { // do something else } ?>
  8. Hi, I've purchased a login script which uses this line to check if the user is an administrator and if so displays a link... <?=($c->is_admin == 'Yes')?'<a href="add.php">Add entry</a>':'<br>'?> My question is, how do I apply this to the following (which is on the same page), where I want to prevent the update and delete links from being visible? I have tried to do it like the example above but receive an error which states that the $row variable is undefined when I do... $row = '<tr> <td>'.$date_added.'</a></td> <td>'.$title.'</a></td> <td><a href="view.php?id='.$id.'">View Details</a></td> <td><a href="update.php?id='.$id.'">Update</a></td> <td><a href="delete.php?id='.$id.'">Delete</a></td> </tr>'; Also, how do I change the admin line to an IF statement e.g. if $c = is_admin {...} else {...} Thanks!
  9. @DavidAM I've tried the following but this doesn't appear to work either... $file_upload = trim(mysql_real_escape_string($_POST["file_upload"])); if(empty($_POST["file_upload"])) { include ('contract_upload.php'); $rsUpdate = mysql_query("UPDATE contract SET date_added = '$date_added', file_upload = '$upload_path' WHERE id = '$id' ");} else { $rsUpdate = mysql_query("UPDATE contract SET date_added = '$date_added' WHERE id = '$id' ");} if($rsUpdate) { echo "Successfully Update";} else { die('Invalid query: '.mysql_error());; }
  10. OK In that case how to I work out if it contains a value or not?
  11. Does anyone know why this won't work. Even when nothing is entered into the file upload field, it is processed as if something was... $file_upload = trim(mysql_real_escape_string($_POST["file_upload"])); if(isset($file_upload)) { include ('contract_upload.php'); $rsUpdate = mysql_query("UPDATE contract SET date_added = '$date_added', file_upload = '$upload_path' WHERE id = '$id' ");} else { $rsUpdate = mysql_query("UPDATE contract SET date_added = '$date_added' WHERE id = '$id' ");} if($rsUpdate) { echo "Successfully Update";} else { die('Invalid query: '.mysql_error());; } [EDIT] This is for an update form by the way, hence why I don't want to overwrite the $upload_path record in the database if a new file is not uploaded...
  12. OK! Thanks for your help.
  13. Is that the correct code to use then if I want to include upload.php if a value is submitted?
  14. Hello! Please could someone have a look at the following code and suggest why upload.php is not being included. I basically want to test whether the form field (upload) contains a value (local file path). If it does contain a value I want to include a file upload script but if it doesn't I want to continue to the next section which processes the form. Due to the way the rest of the code is structured I can't check for a blank field first before continuing to the next step. $upload = trim(mysql_real_escape_string($_POST["upload"])); if(!isset($upload)) { include 'upload.php'; } else {
  15. Sounds simple! Perhaps that's the way to go!
×
×
  • 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.