PHP - Php Not Fully Running
Hi,
Im trying to create a really simple password protected page that is fairly secure but when the user doesnt enter a password the wrong error is displayed. Can anyone see a problem? Also could someone please check that im properly compairing the hash password of 2135fa0dd7fb99d167b420b7ff34ec98 with what the user entered when its hashed? login.php <?php session_start(); ?> <?php $submit = $_POST['submit']; $password = md5($_POST['password']); if ($submit) { if ($password) { if ($password == '2135fa0dd7fb99d167b420b7ff34ec98') { $_SESSION['user'] = logged; header('Location: page.php'); } else { header('Location: index.php?id=1'); } } else { header('Location: index.php?id=2'); } } else { header('Location: index.php?id=1'); } ?> index.php <?php $id=$_REQUEST['id']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Keys</title> <link rel = "stylesheet" type = "text/css" href = "css/layout.css" /> </head> <body> <div id="header"> <h1>Keys</h1> </div> <div id="secondheader"> </div> <div id="main"> <form method="POST" action="login.php"> Password: <input type="password" name="password" onfocus="selected(this)" onblur="notselected(this)"> <input type="submit" name="submit" value="Login"> </form> <br/> <?php if ($id==1) { echo "Invalid password. Please try again"; } elseif ($id==2) { echo "Please enter a password"; } ?> </div> <div id="footer"> </div> <div id="left"> </div> </body> </html> Thanks in advance. Similar TutorialsI have used the XAMPP installer to install php and MySQL locall on my computer. I also succeeded in setting the security for XAMPP pages, the MySQL admin user root and phpMyAdmin login. When I enter phpMyAdmin via the link in the XAMPP initial page I do however receive a red notification: phpMyAdmin configuration storage is not fully configured; some extensions are not activated. To find out click here. I have attached a screenshot showing three items which are not OK, shown in red. I looked up in the documentation, but could not find out. I hope someone can help. I don't even know if it is important to fix this problem. Regards, Erik Attached Files XAMPP2.jpg 41.08KB 0 downloads Is w3c a truce source to follow for any errors found on a website?
For eg. I have my links setup like this. < a href="record.php?id=4&user=smith"></a>
W3C is tell me to not use "&" symbol and that instead escape it as &
So what do I just replace & with & in all my links?
Dear friends, I wrote a code to extract a text from a pages of a site like this: ************ $handle = @fopen($url, 'r'); $contents = ''; if ($handle) { while (!feof($handle)) { $contents .= fread($handle, 8192); } ************ This code is working properly with many pages just pages those are began with the following tags: ************ ... <body> <form name="aspnetForm" method="post" action="ViewContents.aspx?Contract=cms_Contents_I_News&amp%3br=721192" id="aspnetForm"> <input type="hidden" name="__VIEWSTATE" id=" __VIEWSTATE" value="" /> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwL+raDpAgL3qPzdCwLyp86ZD5mqDm6ZnRL/pRerpqyobvzmy5LB" /> ************ The result of function read() in variable $content is not full. It's just theme of the page without main content. I mean there isn't the story related to id of page (e.g. 721192) in the $content. Why? Is the above <form> affected the result? What can i do? Please help me. Hi could anyone help me please. Hey all, I'm working on a website to show various products. I am using PHP, HTML, MySQL. I have a products page which shows a table of products (either all or just products from a specific category). Currently, the page works fine, shows an image, brand, name, and price of each product. However, when I have tried to make the image and the brand and name a link, it doesn't fully work. In the page source it will show correctly, but on the webpage itself I cannot click on the links. I have scoured various forums and manuals and have tried all the various ways to code the <a href=> but it still does not work right. Here's a snippet of the code with the link... Code: [Select] /*Other code above for MySQL queries, HTML table etc*/ <td> <?php echo '<a href="details.php?id=' . $row['id'] . '"><img src="resize.php?id=' . $row['id'] . '"/></a>'; ?> </td> <td> <?php echo "<a href=\"details.php?id=" . $row['id'] . "\">" . $row['brand'] . "<br>" . $row['name'] . "</a><br>"; echo "Price: $" . $row['price'] . "<br>"; ?> </td> I have even tried putting the <a href="details.php?id=<?php echo $row['id']; ?> ... </a> just between the <td> and </td>. I still can't click the links on the page, even though they are technically there. The page source will show <a href="details.php?id=1"> ... =2"> ... =3"> ... etc for each product that is displayed. If I actually type details.php?id=1 in my browser and go back to the products page the text will change color to the "visited link" color. Any insight into my dilemma? Thanks in advance... This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=358359.0 Hello All,
I'm having trouble trying to "wrap my head around" how I can make the query in my code below more efficient, elegant, and certainly immune to a SQL-injection attack
So, I have a form (which can be seen in the attached screenshot) which has the user first select a search-type via a dropdown listbox. The two choices pertain to two columns in the underlying table i.e. store_name and item_description. Once that selection is completed the user is expected to enter a search-term (which is typically in relation to the choice selected in the first prompt).
Now, what I would like to happen is that the query be created based on both, the value in the search-type prompt, as well as the value in search-term textbox, and of course, the query must be a parameterized prepared statement (to minimize the possiblity of a SQL-inection attach).
Essentially I would like to get rid of the following code (which I believe is potentially redundant, and contains a hard-coded column name between the WHERE and LIKE), to make things less complicated and more elegant/flexible
if ($searchtype == "store_name") { $sql = "SELECT * FROM `shoplist` WHERE store_name LIKE :searchterm ORDER BY store_name ASC"; } else if ($searchtype == "item_description") { $sql = "SELECT * FROM `shoplist` WHERE item_description LIKE :searchterm ORDER BY store_name ASC"; }Here's what I tried: // Tried this first but it didn't work...gave some kind of error pertaining to the parameter 2 // Prepare the query ONCE $query = "SELECT * FROM `shoplist` WHERE ? LIKE ? ORDER BY ? ASC"; $searchterm = '%' . $searchterm . '%'; $statement = $conn->prepare($query); $statement->bindValue(1, $searchtype); $statement->bindParam(2, $searchterm); $statement->bindValue(3, $searchtype); $statement->execute(); // ----------------------------------------------------------------------------------------------------------- // // Tried this as well, but was getting unexpected results (mostly all rows being returned, regardless of input) // Prepare the query ONCE $query = "SELECT * FROM `shoplist` WHERE :searchtype LIKE :searchterm ORDER BY :searchtype ASC"; $searchterm = '%' . $searchterm . '%'; $statement = $conn->prepare($query); $statement->bindValue(':searchtype', $searchtype); $statement->bindValue(':searchterm', '%' . $searchterm . '%'); $statement->execute();Here's the complete code (pertaining to the problem/request): // create short variable names if(isset($_POST['searchtype'])) { $searchtype=$_POST['searchtype']; } if(isset($_POST['searchterm'])) { $searchterm=trim($_POST['searchterm']); } if(isset($_POST['searchtype']) && isset($_POST['searchterm'])) { if (!get_magic_quotes_gpc()) { $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); } } if(isset($_POST['searchtype']) && isset($_POST['searchterm'])) { // ****** Setup customized query ****** if ($searchtype == "store_name") { // The following statement is potentially open to SQL-inection attack and has therefore been REM(arked) // $sql = "SELECT * FROM `shoplist` WHERE " . $searchtype . " LIKE :searchterm ORDER BY store_name ASC"; // The following may not be open to SQL-injection attack, but has the column name hard-coded in-between the WHERE and LIKE clauses // I would like the the column name to be set based on the value chosen by the user in the form dropdown listbox for "searchtype" $sql = "SELECT * FROM `shoplist` WHERE store_name LIKE :searchterm ORDER BY store_name ASC"; } else if ($searchtype == "item_description") { // The following statement is potentially open to SQL-inection attack and has therefore been REM(arked) // $sql = "SELECT * FROM `shoplist` WHERE " . $searchtype . " LIKE :searchterm ORDER BY item_description ASC"; // The following may not be open to SQL-injection attack, but has the column name hard-coded in-between the WHERE and LIKE clauses // I would like the the column name to be set based on the value chosen by the user in the form dropdown listbox for "searchtype" $sql = "SELECT * FROM `shoplist` WHERE item_description LIKE :searchterm ORDER BY item_description ASC"; } $statement = $conn->prepare($sql); $statement->bindValue(':searchterm', '%' . $searchterm . '%'); $statement->execute(); ... ... ... }Thanks guys! Attached Files Search-Screen-SS.png 21.31KB 0 downloads Greetings. I'm working on a Wordpress site utilizing a fully-responsive theme ( www.ailimconsulting.com ). One of the features that was requested was the integration of a special menu hover effect found at GitHub that creates a shadow below the menu item being moused over ( you can see this effect by visiting the link above ). As part of the fully responsive nature of the theme, when the browser collapses to a certain point or the site is viewed on mobile devices the menu itself collapses to a single-tabbed system. The problem is that the class that controls the shadow float causes this collapsed menu to look like crap. So, we want to remove the directives of this class from all the mobile viewing settings ( the @media controls ).
The effect is added to the menu via the Appearance / Menus in the CSS Classes field in each menu item with the class name of .float-shadow.
The effect works perfectly in full browser mode but needs t be removed from all the @media sections of the CSS that control the fully-responsive nature of the theme in various devices dimensions. For example, these are the @media directives:
/*-------------------[320px]------------------*/ So I've coded this to run the while loop once for every server within the the table, there is currently two rows within the table and the while loop wont stop running it just keeps on running until I restart Apache, its producing the same effect as what "while(1)" would do, could anybody tell me what the problem could be?, thanks for your time in advance. class bot_restart { function __construct( ) { while($CurrentServers = mysql_fetch_array(mysql_query("SELECT * FROM xhost_boxs"))) { echo $CurrentServers['box_id']; } } } Hey Guys, I have a DB with two tables, one is field names, the other is the data. So for example, I log in and I am user ID 1..... I need to query the DB to show all fields where user_id = 1 Field1 - Data1 Field2 - Data2 etc etc... This is what I have so far, but I dont get any output... $sql = "SELECT * FROM ".WPSC_TABLE_DATA." WHERE `user_id` == .$cu. ORDER BY id DESC"; $user= $wpdb->get_row($sql); while($user) { echo $user->name .' : '. $user->value .'<br />'; } Can you help please? I want to run a php file which contains a long process and takes time. If I simply run the file on browsers, the process will be interrupted by any perturbation in the internet connection or closing the browser. How I can force the php process to continue running without connection to my local PC (server side controlling)? I am looking for something like what cron job does (but only one time, not periodically). Hi, actually the problem is i have been modifying a website, which has been already built and working. so i have all the code and everything, i need to keep it running to make changes. But i m facing problems like above Warning: require_once(../../global-inc.php) [function.require-once]: failed to open stream: No such file or directory in C:\\Apache2.2\htdocs\login.php on line 2 Fatal error: require_once() [function.require]: Failed opening required '../../global-inc.php' (include_path='.;C:\php5\pear') in C:\\Apache2.2\htdocs\login.php on line 2 please let me know what to do ... and the other thing is i need to execute the entire file of code at a time .....can u please tell me the process of doing it .......... thanks in advance shiva shiva I am using MAMP on my MacBook and don't understand why MAMP and my code in NetBeans will not run if I am offline? If I am trying to execute PHP files locally on my laptop, why should MAMP or Apache of NetBEans care if I do not have an Internet connection?! I wanted to show someone something at work where there is no Internet access, but that won't work as it currently stands. TomTees ok. this may make now sense at all, I will try to explain as best as I can. anyways, what I need is for a mysql query to run that will pull all data from table payment between certain days. Then all the rows will show, but I want only one row with each cart_id(there will be multiple) to show. After it does that, in a new column on a table, all the payment types with the amount will show with a slash between each one. I want all of this in a table generated from a php loop. maybe a visual represenation will be better. I hope the picture I attached makes a bit more sense. Hi, I have a PHP script which I want to run from a different IP on my server. Example of what I want to do: My main ip: 4.5.6.7 Have several IP's on server. I want my PHP script (running from CLI) to use cURL with another IP, ay 4.5.6.9 Is this possible to do? Help would be greatly appreciated! Hi I've got a qry that selects 100 questions one at a time from tblquestions. When the users have answered q100 I want them to be able to come out of the post-process-post loop that has taken them through the survey. My idea is that I could put an IF requirement in before the qry runs each time it selects the next question i.e. if $nextq <101 $result = mysql_query("SELECT oid,psc9 FROM tblquestions WHERE oid = $nextq"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }; else echo "thanks you've finished now"; Two Questions: Is this the way I should be going about this problem? Have I got the syntax right? Many thanks! Nick I am trying to display a js dialog box when someone wants to delete something. Currently I have it all with buttons and PHP in the background. When they click the delete icon, I want a dialog box to appear with OK or Cancel. On cancel, return back to the same page, If OK, I want it to run the PHP/mysql code that deletes the record from the DB. Once deletes, I want the box to appear again saying it was deleted successfully. I found this but now sure how to make it work. function show_confirm() { var r=confirm("Press a button"); if (r==true) { alert("You pressed OK!"); } else { alert("You pressed Cancel!"); } } Hey, I am a bit of a noob at php/mysql and trying to be clever(emphasis on trying). I want to pull some php/html code from a database in mysql, whilst it does display the html, the php does not. Can this even be done? Is it going to cause me issues later on? Code: [Select] [php] <?php $query = "SELECT * FROM pages"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)){ $body = $row["body"]; echo $body; }?> [/php] Any help would really be appreciated. Ell I am running some php via a cron and I was after the best way to achieve this. Currently I am doing it as follows:- Code: [Select] 0 * * * * lynx -dump http://www.domain.com/script.php This works fine but I don't want anybody being able to run the script by pointing their browser to the file. Any advice on the best method? Cheers. So I have a php script in public_html on my apache server, and it runs a global economy code for my browser game. If I open firefox and go to: http://localhost/Economy.php it runs the code, and it changes all the values in the database properly. How do I get that to run automatically, say every 6 minutes? I have windows so no cron jobs. I went to task scheduler and created a task which I thought would work, and it lists the task as running. But it gives me an error. Event Views: Code: [Select] Log Name: Microsoft-Windows-TaskScheduler/Operational Source: Microsoft-Windows-TaskScheduler Date: 9/28/2011 5:02:37 PM Event ID: 101 Task Category: Task Start Failed Level: Error Keywords: (1) User: SYSTEM Computer: Matt-PC Description: Task Scheduler failed to start "\Economy" task for user "Matt-PC\Matt". Additional Data: Error Value: 2147750687.Event Xml: Code: [Select] <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{DE7B24EA-73C8-4A09-985D-5BDADCFA9017}" /> <EventID>101</EventID> <Version>0</Version> <Level>2</Level> <Task>101</Task> <Opcode>101</Opcode> <Keywords>0x8000000000000001</Keywords> <TimeCreated SystemTime="2011-09-28T22:02:37.967669800Z" /> <EventRecordID>18</EventRecordID> <Correlation /> <Execution ProcessID="1012" ThreadID="1484" /> <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel> <Computer>Matt-PC</Computer> <Security UserID="S-1-5-18" /> </System> <EventData Name="TaskStartFailedEvent"> <Data Name="TaskName">\Economy</Data> <Data Name="UserContext">Matt-PC\Matt</Data> <Data Name="ResultCode">2147750687</Data> </EventData> </Event> EDITed for code tags |