PHP - If Statments Triggering On Page Load
can someone please help me with this
I'm trying to make it so that when the page loads just the condition below will happend unless the if statment happends. so I need two if statments that work off of one condition? so i was thinking of using OR but i would need a if statement that says the page is being loaded what this code does it displays someones profile when search is hit but i want it to display the persons own profile soon as the page is loaded first Code: [Select] <?php if(isset($_POST['search'])) { // searches goaulds then displays them $search3 = "SELECT goauld,id FROM users WHERE goauld='".mysql_real_escape_string($_POST['goaulds'])."'"; $search2 = mysql_query($search3) or die(mysql_error()); WHILE($search1 = mysql_fetch_array($search2)){ $grab_goauld = $search1['goauld']; echo '<table width="300" height="5" border="1" align="center">'; echo '<th><center>Goauld Statistics</center></th>'; echo "<tr><td height='340'>$grab_goauld</td></tr>"; } } echo '</table>'; ?> Similar TutorialsI'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead! I got two statments: "SELECT id FROM approvednotes WHERE authoer = '$username'"; "SELECT nid FROM usersdownloaded WHERE username - '$author'"; and then once I get results from both of those I want to search approved notes again using only the matches from the statements above and what I want to select this time is "SELECT * FROM approvednotes WHERE md5 ='$md5'"; But I dont actually want to search all the listings just the ones that returned true in the first two statements, is there a way to join these three statements into one? I hope I made myself clear if not let me know and ill try to reexplain. I have a page with results from a query that displays that has a link (works fine - passes variables etc) that deletes that line item from a database. It goes to the delete.php and actually executes and removes the item from the database and then has the line header("Location: page.php"); which returns BACK to the page displaying the results. However, it shows the old results until I hit Refresh in the browser. Its like the header is redirecting to a cached version of the page.
NOTE: This script used to work fine untouched when we where on a shared hosting account. We JUST updates to VPS hosting by the same host. Now this problem has risen and I can't figure out what is wrong. From what I can guess is there is something in php.ini that is either not set, set or set wrong. Any help would be greatly appreciated.
Thanks.
Hello, I have been banging my head against the walla and trouble shooting this for days now. It seems so simple, yet there is something going on that I can't figure out. Thanks so much in advance for the help I am currently limiting comments and replies to comments on my social network. I have successfully done so except on the replies for one page, I can not get php to display an error with a simple if statement that should be firing when the submit button is hit. It's important to know that I have TWO pages being used. The main structural page and then the content page that is included in the structural page. Here is the code: Code: [Select] [code]if(isset($_POST['sub_comment_reply'])) { if($_POST['reply'] == "" ) { $valid = false; $error_msgs_reply[] = "Whoops! You forgot to write your reply."; }else{ $query = "SELECT COUNT(*) FROM `CysticAnswers_replies` WHERE `FromUserID` = $auth->id AND `date` = CURDATE()"; $result = mysql_query($query, $connection); $post_count = mysql_result($result, 0); $max_reply_per_day = 5; $error_msgs_replies_max[] = "Whoops! You have reached your limit of replies for the day."; if($post_count >= $max_reply_per_day){ $valid = false; } else { $query = "INSERT INTO `CysticAnswers_replies` ( `QuestionCommentID`, `FromUserID`, `comment`, `status`, `date`, `time` ) VALUES ( '" . mysql_real_escape_string($_POST['comment']) ."', '" . $auth->id ."', '" . mysql_real_escape_string($_POST['reply'])."', 'active', '" . date("Y-m-d") . "', '" . date("G:i:s") . "')"; mysql_query($query, $connection); } // this is from the page that is included, to echo the error but the if is not triggering <?php if(isset($_POST['sub_comment_reply']) && $post_count >= $max_reply_per_day && $valid = false) { foreach($error_msgs_replies_max as $msg) { ?> <div id="error_x"> <?php echo $msg; ?> </div> <?php } }?>[/code] The below isn't triggering the second if statement: if($_GET['admincp']!=""){ echo '<div class="center"><a href="./index.php?admincp">Admin CP</a>'; if($_GET['do']=="edit"){ (isset($_GET['id']) ? ' &#187; <a href="./index.php?admincp=users&do=edit">Edit Users</a>' : ''); } elseif($_GET['view']=="accounts"){ (isset($_GET['id']) ? ' &#187; <a href="./index.php?admincp=investors&view=accounts">View Accounts</a>' : ''); } echo '</div>'; } When a user is at index.php?admincp=users&do=edit&id=someid they should see Admin CP >> Edit Users When a user is at index.php?admincp=investors&view=accounts&id=someid they should see Admin CP >> View Accounts Right now only Admin CP shows up. is it possible to get an ajax call to execute a php script that will continue running even if the user leaves my site? i have used cron jobs and tokens to do in past but this can result in 1 min delay. First of all, I apologize for my "newbieness" in advance. I've got a form processing script that is working fine except for one section of code, snippets of which is shown below:
//default values $formResponse = "How are you really doing? Use this to find out!"; $imgSource = "blue.png"; If ($country == "United States") { //US zip code query $sql = "SELECT location, revParData FROM zipData WHERE zipCode = '$zipCode' LIMIT 1"; mysql_select_db('db'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { $formResponse = "It looks like you entered an invalid zip code. Please try again!"; $imgSource = "yellow.png"; } else { $sql = "SELECT location, revParData FROM zipData WHERE zipCode = '$zipCode' LIMIT 1"; mysql_select_db('db'); $retval = mysql_query( $sql, $conn ); while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { $location = $row['location']; $revParData = $row['revParData']; } }What I thought would happen is this: If the zip code entered by the end user does not exist in the table, the $formResponse and $imgSource values would be the "... invalid zip code" and "yellow.png" values. If a valid zip code is entered, it completes the second query. In fact, it works fine if a zip code that exists in the table is entered, but shows the default values for $formResponse and $imgSource if a zip code that doesn't exist in the database is entered. I can't figure out why it is doing this... if anyone can point out my coding error, it would be appreciated. Cheers! Mike Hello frnds, Im new in ur forum....I want to know that my one page is taking too much time to load....in that page no images exists..but on that page around 6000 records are loding from database....I m confuse that may be such a large records it is taking too much time...so will u help me out that what can i do so the page can be loaded quickly with these records.... this is urgent for me.....pls pls pls....give me solution soon Thnx a lot in advance Hi! I am looking for a script that counts how many queries is executed on page load? I hadn't realised one of my scripts was doing hundreds of queries simultaneously and never would of thought this would be the cause of high load. As I'm developing stuff in PHP, I want to ensure minimum queries are executed especially because I am doing this in a procedural manner and not OOP. Thanks in advance. Hi, I've been wondering if it is possible to load a php page according to certain time. For example at 12:00 pm a php form will pop up automatically informing an employee to fill in something in the form, another form will pop up at 4:00 pm, etc... Thanks in advance I have a page that processes a variable passed in the url to go get information out of a text file in JSON format. For some reason though, passing one variable loads a page, passing a certain variable (who's data in the file is virtually identical to the first) will cause the browser to just load the page indefinitely. Maybe even more strange is that on my local machine, the variable that won't load is switched, and the other loads fine. How can I debug what's happening when the page never loads so that I never get an error? When a person visits my site I would like for the form on the page to submit and reload with the predetermined search criteria. Is this possible? So for example...if you visited my site as soon as you entered the from would submit and display Google search results for "php freaks" I tried header("location: mysite.com?q=php+freaks"); but that is a continuous loop. -Any thoughts hello, i want to get into a particular page if the user stays more than lets say 20 minutes to automatically load another php page. More specific i have a page which is a test. The user answears to some multiple choice questions. i want him to have only a particular time to anwear. Lets say after 20 min i want to load the results page. Any ideas? Hey, I need to generate a script which tells me how long it takes for an external page to load... Please can you help? Thanks I'm trying to block access to a particular page if the visitor is not from a specific country (using Maxmind Geoip Country database), but not quite sure how to code this properly: I tried this and many variations of this inside the head tags, bud doesn't work. Any suggestions on the best way to go about this? Code: [Select] <?php require_once("geoip.inc"); $gi = geoip_open("/home/username/GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); if($country_code !== 'US') header("HTTP/1.0 404 Not Found"); exit; ?> Is there some way of a php include which is visible on every page (footer), itself having two php includes, but only one of which would be visible, then on the user refreshing the page or on visiting another page on the site, that include would be replaced with another php include? Preferably done without any js. Any help appreciated. Chris Hi, I have a div which reloads every 10 seconds but I want it so that if it equals something then redirect the whole page when at the moment it just loads the whole page in in the div but need the div as it stores all my variables, anyone know of anything else I can use? Thanks Hi,
I am trying to make a page where the footer is loaded according to the screen size, so if someone is accessing the website via a tablet will be a footer, if it is from the computer, there will be another footer.
my problem is that although it is recognizing the windows width, it is not changing the footer accordingly.
this is my code:
$width = "<script>document.write(window.innerWidth);</script>"; if ($width < 900) { include("footer_mobile.php"); } else { include("footer.php"); }for some reason it is always loading the else footer even though the windows with changes. I added echo"$width" ; and the result of the variable was fine. does anyone know what the problem is cause it is driving me crazy? So I have a page that has profile images basically, but these images cache and when someone clicks on anything, like rotate image, since my script rotates the image and saves it correctly, I can hit Ctrl+F5 and the image then shows up correct, but the page loading itself after running my script using a get method and then using the header coming back to the same page the image looks like it wasn't reloaded. Noones gonna hit Ctrl+F5, so how do I get this to cache the image completely when the page reloads? I've tried <meta http-equiv="pragma" content="no-cache" /> But this doesn't work, well nothing seems to work really. Hello All,
I have been going crazy trying to figure this out, I hope someone can help me out
I have header and footer.php files that on all my pages I get them to load with include,
but for some strange reason, this certain page it will not load I did some research and apparently theres problems with div and php, does anyone know how to make this work?
Thank you in advance,
Elaine
Attached Files
test.txt 4.81KB
7 downloads |