PHP - Server Status Check
I got this code off of this forum
Code: [Select] <?php $ip="{$_GET['ip']}"; $port="{$_GET['port']}"; header('Content-type: image/png'); if(!$sock=@fsockopen($ip,"$port", $num, $error, 5)) { readfile('image/offline.png'); } else { readfile('image/online.png'); } ?>I'm able to check the status by going to Code: [Select] http://domain.com/statuscheck.php?ip=google.com&port=80 and it works fine. But I would like to show the status on my index.html page without having to click on a link. Is there anyway Please help. thank you in Advance. Similar TutorialsHello, I made a server statuc checking script that checks the status of a game server. It works fine on my computer, but when I upload it to my web host it stops working. I'm assuming my web host is blocking it in some way. My host is Yahoo Small Businesses. Does anyone know if they block this kind of thing, or if there is a way to unblock it? Perhaps editing the code? Here is my code, if that helps. Code: [Select] <?php function GetServerStatus($site, $port) { $status = array("OFFLINE", "ONLINE"); $fp = @fsockopen($site, $port, $errno, $errstr, 2); if(!$fp) { return $status[0]; } else { return $status[1]; } } $Redemption = GetServerStatus("174.142.118.233", 11661); $RedemptionPossible = GetServerStatus("174.142.118.234", 51665); $Tranquility = GetServerStatus("174.142.118.234", 11601); $TranquilityPossible = GetServerStatus("174.142.118.234", 51665); $Nemesis = GetServerStatus("174.142.118.241", 11601); $NemesisPossible = GetServerStatus("174.142.118.241", 64721); $OverallServer = GetServerStatus("174.142.118.237", 11093); $CodServer = GetServerStatus("8.9.6.122", 4230); echo($CodServer . "<br />"); echo("Overall Server: " . $OverallServer . "<br />"); echo("Redemption: " . $Redemption . "<br />"); echo("Tranquility: " . $Tranquility . "<br />"); echo("Nemesis: " . $Nemesis . "<br />"); ?> Hi all, I have this script I used on a site hosted on my machine that checked if different servers and applications were running on my machine. Here's the code. Code: [Select] <html> <body> <style> fd{ color: #000000 font-size:100% } </style> <?php function check_port($port) { $conn = @fsockopen("212.233.xxx.xxx", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('21'=>'FTP', '22'=>'SSH', '25'=>'SMTP', '80'=>'HTTP', '110'=>'POP3', '143'=>'IMAP', '3306'=>'MySQL', '8080'=>'HFS', '8081'=>'Webcam', '3784'=>'Ventrilo'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <center> <table> <tr> <td><font face="Verdana" size="1" color="#000000">Apache:</td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['HTTP'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">MySQL:</td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['MySQL'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">HFS:</td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['HFS'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">FTP:</font></td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['FTP'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">Webcam:</font></td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['Webcam'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">Ventrilo:</font></td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['Ventrilo'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> </table> </center> </body> </html> I've added the HTML too. As you can see it checks if the ports are open. It worked perfectly and I didn't have any issues with it at all. Now, for a couple of days, I've been using an awardspace paid hosting, bought a domain name. I use wordpress now, and I pasted this code directly in a PHP/HTML code box (I use a plugin that enables use of PHP) and it shows the HTML formatting how it should be, but unfortunately doesn't work as intended. It shows everything to be down, while apache, mysql and my ftp server are still running on my computer (the IP it checks, 212.233.xxx.xxx). When I set the IP to be 127.0.0.1, the IP of the awardspace server as far as my script is concerned, it shows only that the IP is working. So, any suggestions? Any idea would be greatly appreciated Hello I recently got a "to many connection" error on my site, and want to know if anyone here knows a few codes that will show how many connection currently are in use (maybe even what files that creates them). I found I can use "Threads_connected" to show current open connections, but no info on how to write the code or where to pu the file. I hope you can show my what to do I am trying to make a Server Status checker that uses a image to tell if it is online or not. I also am trying to make it so you can the URL as a image code(EX: http://Http://domain.com/statuscheck.php?ip=google.com&port=80). What I'm trying to say it, that if you do like <img src="http://Http://domain.com/statuscheck.php?ip=google.com&port=80"> it would go to my site, use the php script, and then have the image Online or Offline, were the <img> code was posted. Here's my code Im trying to make it from. <?php $ip="{$_GET['ip']}"; $port="{$_GET['port']}"; if(!$sock=@fsockopen($ip,"$port", $num, $error, 5)) { Header('Content-type: image/png'); echo"<img src='images/offline.png'>"; } else { Header('Content-type: image/png'); echo"<img src='images/online.png'>"; } ?> Hi all! Yet again I have a problem. I really couldn't find what the heck's wrong with this thing. It's extremely simple and still... I'm trying to put a php script in my website to monitor the status of my FTP and HFS servers. Help? <TITLE>Server Status</TITLE> <?php $data .= " </div> <center> <div style=\"border-bottom:1px #999999 solid;width:480;\"><b> <font size='1' color='#3896CC'>Server Status</font></b> </div> </center> <br>"; //configure script $timeout = "1"; //set service checks $port[1] = "80"; $service[1] = "Apache"; $ip[1] = "localhost"; $icon[1] = "habbo.jpg"; $alt[1] = "Apache"; $port[2] = "8080"; $service[2] = "HFS Server"; $ip[2] = "localhost"; $icon[2] = "web.png"; $alt[2] = "HFS Server"; $port[3] = "21"; $service[3] = "FTP Server"; $ip[3] = "localhost"; $icon[3] = "web.png"; $alt[3] = "FTP Server"; // // NO NEED TO EDIT BEYOND HERE // UNLESS YOU WISH TO CHANGE STYLE OF RESULTS // //count arrays $ports = count($port); $ports = $ports + 1; $count = 1; //beggin table for status $data .= "<table width='480' border='1' cellspacing='0' cellpadding='3' style='border-collapse:none' bordercolor='#CCCCCC' align='center'>"; while($count < $ports){ if($ip[$count]==""){ $ip[$count] = "localhost"; } $fp = @fsockopen("$ip[$count]", $port[$count], $errno, $errstr, $timeout); if (!$fp) { $data .= "<tr><td width='18' align='center'><img src='http://127.0.0.1/stat/$icon[$count]' title='$alt[$count]' alt='$alt[$count]'></td><td>$service[$count]</td><td width='18' align='center'><img src='http://127.0.0.1/stat/off.png'></td></tr>"; } else { $data .= "<tr><td width='18' align='center'><img src='http://127.0.0.1/stat/$icon[$count]' title='$alt[$count]' alt='$alt[$count]'></td><td>$service[$count]</td><td width='18' align='center'><img src='http://127.0.0.1/stat/on.png'></td></tr>"; fclose($fp); } $count++; } //close table $data .= "</table><div>"; echo $data; ?> The output of this is... Quote Parse error: syntax error, unexpected T_VARIABLE in D:\Program Files\xampp\xampp\htdocs\stat\server.php on line 18 Also, does somebody have a link or something to a tutorial/pre-made script (although I'd like to follow instructions about it) about server statistics? I want to have data on how much a certain partition on the server has free or full. Thank you in advance. Howdy I'm trying to figure out to get a file to call a page on another domain(diffrent server) and check if the activation code matches the one on the activation server. So on the user's server it has a cron job or on load will call my server and run the code in their update.php file against my activation.php file and see if it matches. If($usr == $actv){ //DO THIS }else{ //run disable script } A beginner question.. I have tried "isset" but it aint working.. I wonder what PHP function to use to check if a user actually put a file to be uploaded on the server. A validation just in case a user just click the submit button w/out even choosing a file first. I have this code but it aint working... Code: [Select] <?php if(isset($_POST['submit'])) { if(isset($_FILES['uploaded_file'])) { echo "<span class=\"error_validation\">You haven't choose a logo to upload!<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } else { if($_FILES['uploaded_file']["type"] == "image/gif") { $target_path = "logo/"; $target_path = $target_path. basename('matzhee_logo.gif'); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path)) { echo "<span class=\"error_validation\">The Logo has been successfully changed! Refresh the page to see the changed!<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } else { echo "<span class=\"error_validation\">There was an error uploading the logo. Pls. try again.<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } } else { echo "<span class=\"error_validation\">Invalid file format. We are only accepting image file. Pls. try again.<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } } } else { me_redirect_to("edit_logo.php"); } ?> Anyone? thanks Hi to all;
Is there any way, a function for example in php to add to my script in order to guess if the running script is facing a cpu overload or a memory overload or a slow processing speed ?
Thanks
I have written a small script for my own personal use that checks the servers of my favorite sites to see if they are operational. I'm having trouble getting it to work, I have most of it (I think) and I'm very new to PHP. The script also allows for a form to add any sites to the file, which I think I explode into an array correctly, at a later time. Here's my code, Please Help! <html> <head> <title>project.php</title> </head> <body> <?php $filename = "websites.txt"; $file = file_get_contents($filename); // reads entire file into a string $DomainNames = explode("\n", $file); // split the string at new line characters, returns an array $length = count($DomainNames) - 1; // count is the correct way to get the length of an array $i=0; while($i<=$length){ $fp = @fsockopen ($DomainNames[$i], 80, $errno, $errstr, 10); if (!$fp) echo "$DomainNames[$i] : <font color='red'>Failed!</font>"; else { echo "$DomainNames[$i] : <font color='green'>Online!</font>"; echo "<br>"; $i++; } } if (isset($_POST['submit'])) { $DomainNames[] = $_POST['url']; // append url to array $file = implode("\n", $DomainNames); // convert array to string, delimiting by new lines file_put_contents($filename, $file); // save contents to file } ?> <form action="project.php" method="post"> <fieldset> <label for="url">Url: </label> <input type="text" name="url" id="url" /> <input type="submit" name="submit" id="submit" value="Add URL" /> </fieldset> </form> </body> </html> I've been looking for a simple script that would connect to a game server to see if it is still online. I've found many, but not one of them work. They will permanently send back the text "Online", or "Offline". This is the simplest code I have found: <?php $ip = "66.79.190.40"; $port = "27960"; if (! $sock = @fsockopen($ip, $port, $num, $error, 5)) echo '<B><FONT COLOR=red>Offline</b></FONT>'; else{ echo '<B><FONT COLOR=lime>Online</b></FONT>'; fclose($sock); } ?> I'm also looking into getting it to pull the map name and player-list, but I should be able to figure that out on my own once I get this working. If it helps, this script is supposed to connect to the original Quake games(One, two, and three). Is there a way to run a check on the server to see how long it takes for the page to get built, then print it to the screen?
I tried searching for it online for a few minutes, but it wasn't able to be found. All I'm finding on there is how to optimize the pages, but I want a simple time check performed on the page loading
I need to check (from a Debian server to a Mac CLIENT (not server) machine) to see if a file exists on the file system...not an http server. Here's what I've tried (based on reading at http://www.php.net/manual/en/function.ssh2-exec.php) Code: [Select] <?php function check_remote_files($username, $hostname, $remote_file) { $connection = ssh2_connect($hostname, 22, array('hostkey'=>'ssh-rsa')); if (ssh2_auth_pubkey_file($connection, $username, '/root/.ssh/id_rsa.pub', '/root/.ssh/id_rsa', '')) { echo "Public Key Authentication On Server #2 Successful\n"; } $url = "if ssh $hostname stat $remote_file \> /dev/null 2\>\&1"; $stream=ssh2_exec($connection,$url); stream_set_blocking( $stream, true ); $cmd=fread($stream,4096); fclose($stream); $stream=ssh2_exec($connection,"then"); stream_set_blocking( $stream, true ); $cmd=fread($stream,4096); fclose($stream); $stream=ssh2_exec($connection,"echo File exists"); stream_set_blocking( $stream, true ); $cmd=fread($stream,4096); fclose($stream); $stream=ssh2_exec($connection,"else"); stream_set_blocking( $stream, true ); $cmd=fread($stream,4096); fclose($stream); $stream=ssh2_exec($connection,"echo Not found"); stream_set_blocking( $stream, true ); $cmd=fread($stream,4096); fclose($stream); $stream=ssh2_exec($connection,"fi"); stream_set_blocking( $stream, true ); $cmd=fread($stream,4096); fclose($stream); } ?> NOTHING happens after the echo of Public Key Authentication On Server #2 Successful. I'm running this script from a bash shell. Any ideas what might be wrong? Thanks. Hi All - I'm trying to see if the below is possible using PHP. is it possible for php to allow a user to check if a port is open/listening on a remote server/PC, from their local machine. I've seen scripts on the web that talk about opening cmd.exe - this won't work as not all of my users will be on windows. Also saw fsock.. but the remote server is not serving http page(s). Also saw telnet, but again, some of my users may not have that windows feature enabled. Desired workflow: 1. user enters the server hostname/IP and a port 2. my php webapp will emulate checking if that hostname and port is open from the local user's computer.
thanks! Hey All, I will be marketing a simple php script shortly and would like to Obfuscate my code and have it check to see if the person is running the script on the proper domain, much like other Purchased Scripts, you have to buy licenses and some are limited to a Per Domain basis. Could I use cURL to run a script on another server (mine) that takes the URL it came from, and a variable "the auth key" and check if the person is using the script on the proper domain? If the domain and auth key don't match in the DB i would return a message saying invalid key or something, else continue to execute the script. <?php //authkey would be defined in config file $authkey = "769870afhljkzxf90436"; $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,"http://example.com/page.php?authkey=$authkey"); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); if (empty($buffer)) { print "Sorry, AuthServ is performing maintenance.....<p>"; } else { print $buffer; } ?> Is there a smarter way to do this? I don't have an extra 300 bucks to use something like ioncube, just looking for a general proper direction on going about this as I am totally clueless. thanks I have been looking at this code most of the morning and do not have a clue what is wrong with the code. I am hoping its not a stupid mistake, can someone please help me out? thank you
<title>Inputing Travel Detials</title> <header> <h1 align="center"> Adding Travel Detials </h1> <body> <p> <center><img src="cyberwarfareimage1.png" alt="Squadron logo" style="width:200px;height:200px" style="middle"></center> <table border="1"> <tr> <td><a href="index.php"> Home Page </a></td> <td><a href="administratorhomepage.html">Administrator Home Page </a></td> <td><a href="viewhomepage.html">View Home Page </a></td> <td><a href="Inputhomepage.html">Input Home Page </a></td> <td><a href="traveldetials.html">Enter More Travel Detials </a></td> </table> </p> <?php include "connection.php"; $Applicant_ID = $_POST["Applicant_ID"]; $Method_Of_Travel = $_POST["Method_Of_Travel"]; $Cost = $_POST["Cost"]; $ETA = $_POST["ETA"]; $Main_Gate_Advised = $_POST["Main_Gate_Advised"]; $query = ("UPDATE `int_board_applicant` SET `Method_Of_Travel`=`$Method_Of_Travel', `Cost`=`$Cost', `ETA`='$ETA', `Main_Gate_Advised`='$Main_Gate_Advised' WHERE `Applicant_ID`='$Applicant_ID'"); $result = mysqli_query($dbhandle, $query) or die(mysqli_error($dbhandle)); if($result){ echo "Success!"; } else{ echo "Error."; } // successfully insert data into database, displays message "Successful". if($query){ echo "Successful"; } else { echo "Data not Submitted"; } //closing the connection mysqli_close($dbhandle) ?> Ok this is puzzleing. I am geting "Could not delete data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1". but its is deleting the entry that needs to be removed. The "1" is the entry. Just not sure what is causing the error. I do have another delete php but I have put that on the back burning for the time being.
<?php $con = mysqli_connect("localhost","user","password","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20 "); $amp20ptid = $_POST['amp20ptid']; // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $amp20ptid)); { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?> Hi guys
I have this code below and all works fine when submitting this online application apart from when someone types either ' # & into one of the comment fields in which it throws up the error. Have tried various fixes from across the internet but no joy. Can anyone offer suggestions?
<?php
$con = mysql_connect("localhost:3306","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('sfapp', $con);
$sql="INSERT INTO 'sfapp' ('surname_add','forename_add','dob_add','hometele_add','mobiletele_add','homeadd_add','siblings_add','schoolname_add','headname_add','schooladd_add','schooltele_add','schoolem_add','alevel_add','personstate_add','nameprovided_add','pe_add','se_add','PredGrade_Art','PredGrade_AScience','PredGrade_BusStudies','PredGrade_Electronics','PredGrade_EnglishLang','PredGrade_EnglishLit','PredGrade_French','PredGrade_German','PredGrade_Geog','PredGrade_Graphics','PredGrade_History','PredGrade_Maths','PredGrade_SepScience','PredGrade_ProductDesign','PredGrade_Spanish','PredGrade_Other','Gender_Male','Gender_Female','Sub_EnglishLit','Sub_Maths','Sub_FurtherMaths','Sub_Biology','Sub_Chemistry','Sub_Physics','Sub_French','Sub_German','Sub_Spanish','Sub_Geography','Sub_History','Sub_RE','Sub_FineArt','Sub_Business','Sub_Computing','Sub_GlobPersp','Sub_DramaAndTheatre','Sub_PE','Sub_Dance','Sub_Politics','Sub_Psychology','Sub_Sociology','readprospect_chk','Sib_Yes','Sib_No','Current_Student_Yes','Current_Student_No','I_Understand_chk','Current_Education_chk','Local_Care_chk','Staff_Cwhls_chk','Sub_Film')
VALUES
('$_POST[surname_add]','$_POST[forename_add]','$_POST[dob_add]','$_POST[hometele_add]','$_POST[mobiletele_add]','$_POST[homeadd_add]','$_POST[siblings_add]','$_POST[schoolname_add]','$_POST[headname_add]','$_POST[schooladd_add]','$_POST[schooltele_add]','$_POST[schoolem_add]','$_POST[alevel_add]','$_POST[personstate_add]','$_POST[nameprovided_add]','$_POST[pe_add]','$_POST[se_add]','$_POST[PredGrade_Art]','$_POST[PredGrade_AScience]','$_POST[PredGrade_BusStudies]','$_POST[PredGrade_Electronics]','$_POST[PredGrade_EnglishLang]','$_POST[PredGrade_EnglishLit]','$_POST[PredGrade_French]','$_POST[PredGrade_German]','$_POST[PredGrade_Geog]','$_POST[PredGrade_Graphics]','$_POST[PredGrade_History]','$_POST[PredGrade_Maths]','$_POST[PredGrade_SepScience]','$_POST[PredGrade_ProductDesign]','$_POST[PredGrade_Spanish]','$_POST[PredGrade_Other]','$_POST[Gender_Male]','$_POST[Gender_Female]','$_POST[Sub_EnglishLit]','$_POST[Sub_Maths]','$_POST[Sub_FurtherMaths]','$_POST[Sub_Biology]','$_POST[Sub_Chemistry]','$_POST[Sub_Physics]','$_POST[Sub_French]','$_POST[Sub_German]','$_POST[Sub_Spanish]','$_POST[Sub_Geography]','$_POST[Sub_History]','$_POST[Sub_RE]','$_POST[Sub_FineArt]','$_POST[Sub_Business]','$_POST[Sub_Computing]','$_POST[Sub_GlobPersp]','$_POST[Sub_DramaAndTheatre]','$_POST[Sub_PE]','$_POST[Sub_Dance]','$_POST[Sub_Politics]','$_POST[Sub_Psychology]','$_POST[Sub_Sociology]','$_POST[readprospect_chk]','$_POST[Sib_Yes]','$_POST[Sib_No]','$_POST[Current_Student_Yes]','$_POST[Current_Student_No]','$_POST[I_Understand_chk]','$_POST[Current_Education_chk]','$_POST[Local_Care_chk]','$_POST[Staff_Cwhls_chk]','$_POST[Sub_Film]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
?>
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['pe_add'])) {
//Email information
$admin_email = $_REQUEST['pe_add'];
$forename = $_REQUEST['forename_add'];
$email = "autoreply@testing.com";
$subject = "Application";
$desc =
"Dear $forename
Thank you for submitting your online application, we will be in touch shortly.
"
;
//send email
mail($admin_email, "$subject", "$desc", "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
If you are seeing this, you need to go back and fill out the Personal Email section!
<?php
}
header("location:complete.php");
mysql_close($con)
?>
Thanks in advance.
I have a PHP web system that store in a windows server. In the system, there is a function for user to upload files to another server (Shared server in Unix). When i try to upload a file, it gives warning: Warning: move_uploaded_file(\\unixserver/sharedfolder/upload/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\upload\index.php on line 40 For your information, my username has been assigned in xxx's group that has access to read and write on that folder. Besides, i'm able to open,create and delete files on that folder's server manually (samba). The safe mode setting is off. Does anybody has any idea why this thing happen? Hi, I am not a PHP programmer. I took on a new client with a simple PHP site, without any databases. The site is up and running on the web. I would like to get it running on my local machine for further development. I have latest version of WAMP installed, running Apache version 2.2.11 and PHP version 5.3.0 I created a directory in the WAMP "www" project directory and it shows up there like it's supposed to when I browse to "localhost" Problem: The home page of website displays text but no, images, styles, footer, header, nav links, etc. Here is the code for the home page: <? define("NAV","home"); require_once('local/local.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"> <head> <title>TITLE</title> <meta name="keywords" content=""> <meta name="Description" content=""> <? include("common/dochead.php"); ?> </head> <body onLoad="<? include('common/preloads.php'); ?>"> <!-- ============================ main ============================= --> <div id="main-frame"><div id="main" class="noCollapse"> <? include("common/sign.php"); ?> <div id="right-frame"> <? include("common/navigation.php"); ?> <div id="content-frame"> <div id="content"> <h1>Welcome</h1> <p>This is the content area. This is the content area. This is the content area. </p> </div><!-- end content --> </div><!-- end content-frame --> </div><!-- end right-frame --> <div class="clearFloats"></div> </div><!-- end main --></div><!-- end main-frame --> <? include("common/footer.php"); ?> </body> </html> Any help would be greatly appreciated. I have spent many hours on this. Regards I'm trying to make a simple website where people register to my website. When the user doesn't fill anything inside the boxes they get a message "Please fill all required fields" on the register.php page On my local host require_once works good. It shows up.
But when i upload the files to my sever the require_once does not show up on the register.php It just refreshes and i dont get the message "Please fill all required fields"
This is the code that works in local host but not in a live server <?php require_once 'messages.php'; ?>
Here is my full code
Register page: <html> <?php require_once 'messages.php'; ?> <br><br> <form action="register-clicked.php" method="POST"> Username:<br> <input type="text" name="usernamebox" placeholder="Enter Username Here"> <br><br> Email:<br> <input type="text" name="emailbox" placeholder="Enter email here"> <br><br> Password:<br> <input type="password" name="passwordbox" placeholder="Enter password here"> <br><br> Confirm Password:<br> <input type="password" name="passwordconfirmbox" placeholder="Re-enter password here"> <br><br> <input type="submit" name="submitbox" value="Press to submit"> <br><br> </form> </html>
Register clicked <?php session_start(); $data = $_POST; if( empty($data['usernamebox']) || empty($data['emailbox']) || empty($data['passwordbox']) || empty($data['passwordconfirmbox'])) { $_SESSION['messages'][] = 'Please fill all required fields'; header('Location: register.php'); exit; } if ($data['passwordbox'] !== $data['passwordconfirmbox']) { $_SESSION['messages'][] = 'Passwords do not match'; header('Location: register.php'); exit; } $dsn = 'mysql:dbname=mydatabase;host=localhost'; $dbUser='myuser'; $dbPassword= 'password'; try{ $connection = new PDO($dsn, $dbUser, $dbPassword); } catch (PDOException $exception){ $_SESSION['messages'][] = 'Connection failed: ' . $exception->getMessage(); header('Location: register.php'); exit; }
messages.php <?php session_start(); if (empty($_SESSION['messages'])){ return; } $messages = $_SESSION['messages']; unset($_SESSION['messages']); ?> <ul> <?php foreach ($messages as $message): ?> <li><?php echo $message; ?></li> <?php endforeach; ?> </ul> Edited Wednesday at 12:49 AM by bee65 |