PHP - Custom 404 Pages Linked Into Cms Site
I have no idea where to start or which board would be the proper place to put this but what I"m attempting to do is integrate this idea with my custom cms I'm making now is that once inside I can take down my site in case I (administrator) wanted to perform some maintenance on my site and have it instead display a custom 404 page. Any ideas on where to start. I tried using my best friend google but he gave me nothing. Maybe a few tutorials of this might help.
Similar TutorialsHi, I want to be able to allow user to enter in <input type="text" >... the total XML files to upload on the first page so: my first page has form that asks user how many uploads form they want so (firstpage.html): <form method='post' action='outputTotalUploads.php' >... Then in second form (outputTotalUploads.php) is where it outputs the desired number of upload forms based on the first page: for loop to post each <form method='post' action='addToDb.php' >... Finally in third page (addToDb.php): for each uploaded file, do: //BUT HOW DO I GET THIS TOTAL?? add to database *My problem is HOW do I refer to the total number of uploads the user chose way back in the first page b/c I know you cannot have multiple action attribute in the form tag. Any help much appreciated! Hi im a little stuck... What im trying to do is when you request a page that is not there it goes to a custom error page. I have set the redirect via the .htaccess file. Basicly what im trying to do is only have one php file which displays the server response i.e. 404 error or 401 error and so on rather than having several error pages. So in the code Code: [Select] <h1>Oopppsss!!!! <!-- ERROR TO DISPLAY HERE i.e. 404 page not found --></h1> <p>There seems to be a problem... The page you are looking for does not exist or has moved. This is a permanent error. If you think this is a mistake please get in touch either by giving us a ring on 101010 or by filling out the web form on the <a href="contact-me.php">contact me</a> page...</p> Any thaught on how i can do this or is it not possible... Cheers if I have a list of 5,000 bots and their server header into in my DBs, can someone point me to a web resource that can give me any insight into how to show a custom page if a bot is detected at the render request? I can look up PHP functions myself and possibly use header(), but didn’t know if anything special was involved that I don’t already know about. so, say for instance, as a joke I want to do this: <?php $ip = gethostbyaddr($_SERVER['REMOTE_ADDR']); if (substr($ip, 0, 3) = '10.') { echo 'sorry, but we do not display content to USA government's automated server sniffing bots.'; } ?> how much of a pain in the rear would it be to display custom pages for ‘‘x’’ number of automated hits? I realize that this is pointless because most are just from researching orgs the world over, but it IS a relevant question to ask. thanks. Hi everyone, I am a beginner web designer and a novice php user. I am a regular forum user and understand that you should always do a search and try to find the answer yourself but I have done that and didn't get any results (or I didn't understand them!). So I ask for some assistance - either you can tell me the code or link me to the correct answer. I am working on a website that I have built a enquiry form for and it has a php script for it. I have managed to get the form running properly and got the reCaptcha working correctly (with a custom error page) but I do not understand how to add custom error pages for incomplete email addresses, empty email addresses, or for a blank form? I tried using the same tactic I used for the reCaptcha error page but it didn't work - probably because I was guessing and just tried it in a bunch of different places. The error msg that displays now is just a plain white page with the msg - Email address is invalid appearing at the top left. While this is suitably functional it doesn't really look like much so I want to build a custom page for each error that could happen. So the code is below - if anyone can point a beginner in the right direction I would be super happy. :mrgreen: if you need anymore code or other details just tell me and I will post them up. The url of the form page is http://www.sunsolutionshomeimprovement.com/onlinesales.html This is the code I think you will need - I got it from a demo php script that I have modified. As I said I don't have much clue what I'm doing so I just posted it exactly how it looks - if I over did it I apologize... :oops: 68.// Validate email field. 69. 70.if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) 71.{ 72. 73.if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or 74.a colon";} 75. 76.$_REQUEST['email'] = trim($_REQUEST['email']); 77. 78.if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}} 78. 79.) 80. 81.// Check referrer is from same site. 82. 83.if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} 84. 85.// Check for a blank form. 86. 87.function recursive_array_check_blank($element_value) 88.( 89. 90.global $set; 91. 92.if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} 93.else 94. 95. 96.foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} 97. 98.) 99. 100.) 101. 102.recursive_array_check_blank($_REQUEST); 103. 104.if(!$set){$errors[] = "You cannot send a blank form";} 105. 106.unset($set); 107. 108.// Display any errors and exit if errors exist. 109. 110.if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} 111. 112.if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} 113. 114.// Build message. I don't think there is anymore that is relevant? I just want to reiterate that I know nearly nothing about this stuff so if you could keep your answers simple it would help a lot - cheers! Hi I really need help coding my register.php
please flag any mistakes and suggest additions to the code
please help
<html> <head> <title>______________</title> </head> <body> <h2>Registration Page</h2> <a href="index.php">Click here to go back<br/><br/> <form action="register.php" method="POST"> Enter Company Name: <input type="text" name="Company_Name" required="required" /> <br/> Enter Unit: <input type="text" name="Unit" required="required" /> <br/> Enter Street: <input type="text" name="Street" required="required" /> <br/> Enter Town: <input type="text" name="Town" required="required" /> <br/> Enter County: <input type="text" name="County" required="required" /> <br/> Enter Postcode: <input type="text" name="Postcode" required="required" /> <br/> Enter Country: <input type="text" name="Country" required="required" /> <br/> Enter Phone Number: <input type="text" name="Phone_Number" required="required" /> <br/> Enter Email: <input type="text" name="Email" required="required" /> <br/> Enter Password: <input type="password" name="Password" required="required" /> <br/> <input type="submit" value="Register"/> </form> </body> </html> <?php if($_SERVER["REQUEST_METHOD"]== "POST"){ $Company_Name = mysql_real_escape_string($POST['Company Name']); $Unit = mysql_real_escape_string($POST['Unit']); $Street = mysql_real_escape_string($POST['Street']); $Town = mysql_real_escape_string($POST['Town']); $County = mysql_real_escape_string($POST['County']); $Postcode = mysql_real_escape_string($POST['Postcode']); $Country = mysql_real_escape_string($POST['Country']); $Phone_Number = mysql_real_escape_string($POST['Phone Number']); $Email = mysql_real_escape_string($POST['Email']); $Password = mysql_real_escape_string($POST['Password']); echo "Company Name entered is: ". $Company_Name . "<br/>"; echo "Unit entered is: ". $Unit . "<br/>"; echo "Street entered is: ". $Street . "<br/>"; echo "Town entered is: ". $Town . "<br/>"; echo "County entered is: ". $County . "<br/>"; echo "Postcode entered is: ". $Postcode . "<br/>"; echo "Country entered is: ". $Country . "<br/>"; echo "Phone Number entered is: ". $Phone_Number . "<br/>"; echo "Email entered is: ". $Email. "<br/>"; echo "Password entered is: ". $Password . "<br/>"; } ?> This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=355963.0 Hi, Having completed a site migration this am everything went well aside from issues with logging into and out of our site where two files are used and appear as white pages. When logging into our site, proc_login.php is used and when logging out proc_logout.php is used. Both processes result in a white "blank" page instead of the php files forwarding on. I've no idea about php generally and have been trying my best to find useful and similar information online to attempt to resolve the problem. I am now stuck. The site works perfectly on my local web server, and what is really baffling me is the site also works perfectly on Domain B on the exact same server I'm trying to get the site running under as Domain A. In other words as both Domain A & B are configured on the same host server I'm thinking all the inherited php/apache/mysql settings should be identical (or pretty much thereabouts) and therefore am more confused than ever! I simply don't know where to start therefore in resolving this problem. I've tried looking in the error log file and have also played around with turning on error enabling on those specific php files to try and follow any errors, however the "errors" generated are no different than the ones present on sites where the login/logout process works just fine. I've hopefully attached both files and if anyone could assist in helping me narrow down my search for a solution I'd be very appreciative. Thanks. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=323879.0 I'm sure it's not much, but I'm not understanding something with custom error handlers: I've created a custom error handler, which I initially set when my page loads : set_error_handler(array ( new ErrorHandler(), 'handleError' ));
It seems to catch all internal PHP errors, such as if I: var_dump($non_existing_var); right after the set_error_handler.... Now, I have an object that throws an exception after: set_error_handler(array ( new ErrorHandler(), 'handleError' )); $locale = new \CorbeauPerdu\i18n\Locale(...); // this should throw an exception ... I thought that with an error handler set, I could 'skip' the try/catch for it, but doing so, PHP spits out in its internal log: PHP Fatal error: Uncaught CorbeauPerdu\i18n\LocaleException: ....
My error handler doesn't catch it at all before, thus my page breaks!! If I want it to go through the error handler, I have to init my Locale with a try/catch and use trigger_error() like so: set_error_handler(array ( new ErrorHandler(), 'handleError' )); try { $locale = new \CorbeauPerdu\i18n\Locale(...); // this should throw an exception } catch(Exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); } ... Is this normal ? I thought one of the goals of the error_handler was to catch anything that wasn't dealt with? Thanks for your answers! Hi all, first time posting here and wondering if anyone can help me. Ive linked a button in a HTML so that it sends an email to me. But the thing thats really bugging me is that sometimes it sends the persons email address and sometimes it doesnt AND ALSO ive got multiple boxes in my HTML that I want it to send but it will only send 1 and not all 5. This is what my PHP looks like at the moment: <?php $email = $_REQUEST[ 'email_box' ] ; $message = $_REQUEST[ 'test1_box' ] ; $message = $_REQUEST[ 'test2_box' ] ; $message = $_REQUEST[ 'test3_box' ] ; $message = $_REQUEST[ 'test4_box' ] ; $message = $_REQUEST[ 'test5_box' ] ; mail( "test1049@live.com", "Test Feedback sheet", $message, "From: $email" ); ?> Can you please tell me where I have gone wrong? I really need this to be sorted out and im completely new to PHP, ive only just gotten past basic knowledge of html So I have 3 tables, student, student_course and course. I'm only using student and course atm, probably should look into student_course haha well those are the tables provided to us for the project I'm working on. I'm trying to list all the courses from the course table and then when clicking on a course I want to display all the students who registered for this course( which would probably be the student table) Here is my code for displaying the courses: Code: [Select] <?php $display_sql ="SELECT cname FROM course ORDER BY cid DESC"; $display_query = mysql_query($display_sql) or die(mysql_error()); $rsDisplay = mysql_fetch_assoc($display_query); ?> <html> <head> </head> <body> <p> Click course to display all students registered for that course</p> <?php do { ?> <p><a href="test.php?cname=<?php echo $rsDisplay['cid']; ?>"> Course: <?php echo $rsDisplay['cname']; ?> </a> </p> <?php } while ($rsDisplay = mysql_fetch_assoc($display_query)) ?> And here is my code for displaying the students from the student table registered for the specific course you click on: Code: [Select] <?php $q = "SELECT * FROM student WHERE cname = $_GET[cname]"; $confirm_query = mysql_query($q); $rsconfirm = mysql_fetch_assoc($confirm_query); ?> <html> <head> </head> <body> <p> Displaying all student </p> <p> First Name <?php echo $rsconfirm['sname']; ?> </p> <p> Surname: <?php echo $rsconfirm['fname']; ?> </p> I'm very new to php. Im using "test.php?cname=" to transfer the cname (course name) info from my course table to the next page where I use $_GET[cname]";. cname isn't a primary key in my table, rather just a row. Can it be done like that? Or should you just use primary keys? I managed to display the courses but when clicking it, it wont display the registered users and gives me an error: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Program Files\EasyPHP-5.3.3\www\Project\test.php on line 28 What does that mean? Line 28 is this part : Code: [Select] $q = "SELECT * FROM student WHERE cname = $_GET[cname]"; //26 $confirm_query = mysql_query($q); //27 $rsconfirm = mysql_fetch_assoc($confirm_query); //28 Any criticism welcome. When coding I'm still trying to figure out what it is I'm doing nevermind getting it to work haha. Thanks in advance ...in a different folder? For instance, I have a stylesheet in my C:\xampp\htdocs\rcm folder, and I want to link it to files in the C:\xampp\htdocs\ folder. Is there a way of doing this? Thanks in advance Simplified for everyone's sanity and re-posted.
Got a Wordpress Conference theme, lets you enter speakers into a database and assign each one a category/role. In the settings for the theme, there's a dropdown from which you can select one of the roles you create. Doing so will display all the speakers assigned that role in the footer of the homepage and also populate a stand-alone Speakers page with the same role. I want to make it so that the footer on the homepage displays one role and the stand-alone speaker page displays another. Here's the PHP for the Speakers page (identical to the footer PHP) <?php Here's the HTML for the "dropdown" portion of the settings, where you can see the role categories available. "Speaker" is the default created by the Theme, "whyattend" is the one I made. <!-- Speakers Category --> I want "whyattend" to show on the Footer and "Speaker" to populate the Speakers page. Can this be done? Hi, I have been told it is possible to use PHP to design a left navigation bar which features a submenu for each link clicked on. So if you click "shoes" in the left navigation bar it will then display all the left navigation bar links but below shoes it might have a sub menu saying "Size 5", "Size 6", "Size 7", "Size 8", "Size 9", "Size 10". What function in PHP allows me to include submenus? I think I need to define a 'Foreign Key' and use categories but I do not know what function to use to alter the menu depending on what the user clicks/selects??! Any ideas? Matt. HI, I have a ms-access file which has linked table. The linked table is connected to a ODBC source (e.g MS-SQL or 3rd Party ODBC Driver). WebPage(php) Apache, connecting to a ODBC DSN of MS-Access, MS-Access is having linked tables. Linked tables as from another ODBC source. On the PHP Page, When I am trying to connect the ms-access odbc dsn , I am able to connect. But when I query any of the linked tables, PHP is not able to query and is failing. Does php has capabilities to read/write to linked tables in ms-access file. Or it is issue with MS-Access Or is it I am missing something. Microsoft says, its an issue of PHP https://social.msdn....forum=accessdev Requesting you to please share your feedback Regards Rajendra Dewani This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=347820.0 I have several "sites" located in my html directory, and each has a "general" access point and an "administrator" access point:
/var/www/html/site1/index.php /var/www/html/site1/administrator/index.php /var/www/html/site2/index.php /var/www/html/site2/administrator/index.php /var/www/html/site3/index.php /var/www/html/site3/administrator/index.phpAll sites are similar except that data will be specific to site1, site2, or site3, etc. Users who log onto /var/www/html/siteX/index.php are totally unrelated to those who logon to /var/www/html/siteX/administrator/index.php, will have different logon credentials, are stored in different DB tables, and each should have their own session. If a user logs off of either the general or administrator site, it should not effect the other site even if they were previously logged on to both on the same PC (and of course not effect other sites). When a user logs off, I would like to destroy their previous cookie and associated session. Users for either will only use https. I am using Apache to rewrite https://www.mysite.com/ to https://mysite.com/. While I named the administrator site "administrator" above, the administrator user has the ability to change the directory name. I am thinking I need to use session_set_cookie_params to specify where I wish the session cookie to be stored since /var/www/html/siteX/administrator/index.php is a sub-directory to /var/www/html/siteX/index.php, but am not really sure. Sorry for the cryptic post, but I am not very well versed in this subject. How would you recommend setting up cookies/sessions for this scenario? Thank you Not sure if I'm trying to achieve something totally crazy here, or if this is something pretty standard. Didn't have much luck with searching as I'm not fully down with all the terms. (A) I have one site providing an RSS feed. (B) I have one site I want to search, once for each of the items in the feed A. (C) I want the results of the search in (B) to be displayed on page (C). So for example, the feed on (A) says; apples bananas oranges cheese I want site (B) to search for each of those terms (by passing the item in the feed (A) to the ?search= part of the URL of that page) and then show the results from THAT search on page C. Bit of a complex one, let me know if you need me to clarify. Thanks for any help! |