Webmasterpals  

Go Back   Webmasterpals > Webmasterpals Network > PHP Login Script v2.0

Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2010, 12:30 PM
bian101 bian101 is offline
Member
 
Join Date: Dec 2009
Posts: 42
bian101 is on a distinguished road
Default Getting the nasty "the website cannot display the webpage" error

Hey,

okay. I changed the layout etc ages ago on a page, it worked fine. Out of the blue it decided to stop working! And even when i upload the original mysettings file it STILL gives me the error!!

Any help?

Thanks, here is my modified code.

Code:
<?php 
/********************** MYSETTINGS.PHP**************************
This updates user settings and password
************************************************************/
include 'dbc.php';
page_protect();



$rs_settings = mysql_query("select * from `users` where `id`='$_SESSION[user_id]'");

if($_POST['doUpdate'] == 'Update')  
{

$rs_pwd = mysql_query("select pwd from users where id='$_SESSION[user_id]'");
list($old) = mysql_fetch_row($rs_pwd);
//check for old password in md5 format
	if($old == md5($_POST['pwd_old']))
	{
	$newmd5 = md5(mysql_real_escape_string($_POST['pwd_new']));
	mysql_query("update users set pwd='$newmd5' where id='$_SESSION[user_id]'");
	header("Location: mysettings.php?msg=Your new password is updated");
	} else
	{
	 header("Location: mysettings.php?msg=Your old password is invalid");
	}

}

if($_POST['doSave'] == 'Save')  
{
function filter($arr) {
    return array_map('mysql_real_escape_string', $arr);
}
$_POST = filter($_POST);

mysql_query("update users set pwd='$newmd5' where `id`='$_SESSION[user_id]'");
			`full_name` = '$_POST[name]',
			`address` = '$_POST[address]',
			`tel` = '$_POST[tel]',
			`fax` = '$_POST[fax]',
			`website` = '$_POST[web]',
			 WHERE id='$_SESSION[user_id]'
			") or die(mysql_error());

header("Location: mysettings.php?msg=Profile+Sucessfully+saved");
 }
?>
<html>
<head>
<title>Kendal Air Cadets || My Notes!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery.validate.js"></script>
  <script>
  $(document).ready(function(){
    $("#myform").validate();
	 $("#pform").validate();
  });
  </script>
<link href="styles.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #000000}
.style2 {
	font-size: 14px;
	color: #000000;
}
.style3 {color: #0000FF}
.style4 {color: #0000FF; font-weight: bold; }
-->
</style>
</head>

<body>
<div align="center">
  <table width="84%" border="0" cellspacing="0" cellpadding="5" class="main">
    <tr> 
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr> 
      <td width="130" valign="top"><? 
/*********************** MYACCOUNT MENU ****************************
This code shows my account menu only to logged in users. 
Copy this code till END and place it in a new html or php where
you want to show myaccount options. This is only visible to logged in users
*******************************************************************/
if (isset($_SESSION['user_id'])) {?>
        <div class="myaccount">
          <p><strong>My Account</strong></p>
        <p><a href="myaccount.php">My Account</a><br>
          <a href="mysettings.php">Notes</a><br>
          <a href="resorce.php">Resources</a></p>
        <p><a href="project.php">My Projects</a></p>
        <p><a href="logout.php">Logout </a></p>
        </div>
      <? } 
/*******************************END**************************/
?>
        <p>&nbsp; </p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      <p>&nbsp;</p></td>
      <td width="563" valign="top" class="titlehdr">
        <h3 class="titlehdr style3"><strong>My Settings</strong></h3>
        <p> 
          <?	
      if (isset($_GET['msg'])) {
	  echo "<div class=\"msg\">$_GET[msg]</div>";
	  }
	  ?>
          <? while ($row_settings = mysql_fetch_array($rs_settings)) {?>
        &nbsp;&nbsp;NOTE:&nbsp;This page is under heavy maintinance.</p>
        <form action="mysettings.php" method="post" name="myform" id="myform">
          <table width="100%" border="0" align="left" cellpadding="3" cellspacing="3" class="forms">
            <tr> 
              <td height="198" colspan="5" align="left" valign="top"><p>Your Name
                </p>
                <p>
                  <input name="pro1" type="text" id="pro1"  class="main" value="<? echo $row_settings['full_name']; ?>" size="50">
                </p>
                <p>Any Cadet Related Notes</p>
                <p>
                <textarea name="pro1" cols="50" rows="8" class="main" id="pro1"><? echo $row_settings['address']; ?></textarea>
                &nbsp; </p>
              <p><input name="doSave" type="submit" id="doSave" value="Save">
                &nbsp;</p>
              </td>
            </tr>
          </table>
          <p align="center">&nbsp;</p>
        </form>
        <p>
          <? } ?>
        </p>
        <p>&nbsp;</p>
	         
      <p align="right">&nbsp; </p></td>
      <td width="8" valign="top" class="titlehdr">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="3">&nbsp;</td>
    </tr>
  </table>
</div>
</body>
</html>

Thanks!
Reply With Quote
  #2  
Old 01-18-2010, 11:53 PM
glycerine glycerine is offline
Member
 
Join Date: Oct 2009
Posts: 61
glycerine is on a distinguished road
Default Re: Getting the nasty "the website cannot display the webpage" error

try this hopefully it works
Code:
<?php 
/********************** MYSETTINGS.PHP**************************
This updates user settings and password
************************************************************/
include 'dbc.php';
page_protect();



$rs_settings = mysql_query("select * from `users` where `id`='$_SESSION[user_id]'");

if($_POST['doUpdate'] == 'Update')  
{

$rs_pwd = mysql_query("select pwd from users where id='$_SESSION[user_id]'");
list($old) = mysql_fetch_row($rs_pwd);
//check for old password in md5 format
	if($old == md5($_POST['pwd_old']))
	{
	$newmd5 = md5(mysql_real_escape_string($_POST['pwd_new']));
	mysql_query("update users set pwd='$newmd5' where id='$_SESSION[user_id]'");
	header("Location: mysettings.php?msg=Your new password is updated");
	} else
	{
	 header("Location: mysettings.php?msg=Your old password is invalid");
	}

}

if($_POST['doSave'] == 'Save')  
{
function filter($arr) {
    return array_map('mysql_real_escape_string', $arr);
}
$_POST = filter($_POST);

mysql_query("update users set pwd='$newmd5' where `id`='$_SESSION[user_id]',
			`full_name` = '$_POST[name]',
			`address` = '$_POST[address]',
			`tel` = '$_POST[tel]',
			`fax` = '$_POST[fax]',
			`website` = '$_POST[web]',
			 WHERE id='$_SESSION[user_id]'
			") or die(mysql_error());

header("Location: mysettings.php?msg=Profile+Sucessfully+saved");
 }
?>
<html>
<head>
<title>Kendal Air Cadets || My Notes!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery.validate.js"></script>
  <script>
  $(document).ready(function(){
    $("#myform").validate();
	 $("#pform").validate();
  });
  </script>
<link href="styles.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #000000}
.style2 {
	font-size: 14px;
	color: #000000;
}
.style3 {color: #0000FF}
.style4 {color: #0000FF; font-weight: bold; }
-->
</style>
</head>

<body>
<div align="center">
  <table width="84%" border="0" cellspacing="0" cellpadding="5" class="main">
    <tr> 
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr> 
      <td width="130" valign="top"><? 
/*********************** MYACCOUNT MENU ****************************
This code shows my account menu only to logged in users. 
Copy this code till END and place it in a new html or php where
you want to show myaccount options. This is only visible to logged in users
*******************************************************************/
if (isset($_SESSION['user_id'])) {?>
        <div class="myaccount">
          <p><strong>My Account</strong></p>
        <p><a href="myaccount.php">My Account</a><br>
          <a href="mysettings.php">Notes</a><br>
          <a href="resorce.php">Resources</a></p>
        <p><a href="project.php">My Projects</a></p>
        <p><a href="logout.php">Logout </a></p>
        </div>
      <? } 
/*******************************END**************************/
?>
        <p>&nbsp; </p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      <p>&nbsp;</p></td>
      <td width="563" valign="top" class="titlehdr">
        <h3 class="titlehdr style3"><strong>My Settings</strong></h3>
        <p> 
          <?	
      if (isset($_GET['msg'])) {
	  echo "<div class=\"msg\">$_GET[msg]</div>";
	  }
	  ?>
          <? while ($row_settings = mysql_fetch_array($rs_settings)) {?>
        &nbsp;&nbsp;NOTE:&nbsp;This page is under heavy maintinance.</p>
        <form action="mysettings.php" method="post" name="myform" id="myform">
          <table width="100%" border="0" align="left" cellpadding="3" cellspacing="3" class="forms">
            <tr> 
              <td height="198" colspan="5" align="left" valign="top"><p>Your Name
                </p>
                <p>
                  <input name="pro1" type="text" id="pro1"  class="main" value="<? echo $row_settings['full_name']; ?>" size="50">
                </p>
                <p>Any Cadet Related Notes</p>
                <p>
                <textarea name="pro1" cols="50" rows="8" class="main" id="pro1"><? echo $row_settings['address']; ?></textarea>
                &nbsp; </p>
              <p><input name="doSave" type="submit" id="doSave" value="Save">
                &nbsp;</p>
              </td>
            </tr>
          </table>
          <p align="center">&nbsp;</p>
        </form>
        <p>
          <? } ?>
        </p>
        <p>&nbsp;</p>
	         
      <p align="right">&nbsp; </p></td>
      <td width="8" valign="top" class="titlehdr">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="3">&nbsp;</td>
    </tr>
  </table>
</div>
</body>
</html>
Reply With Quote
  #3  
Old 01-20-2010, 03:30 PM
bian101 bian101 is offline
Member
 
Join Date: Dec 2009
Posts: 42
bian101 is on a distinguished road
Default Re: Getting the nasty "the website cannot display the webpage" error

Thanks! The page works now, only thing is when i submit it it returns this error:

"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 ' `full_name` = '', `address` = '', `tel` = '', `fax` = '', `websi' at line 1"

so it could be the bit that is here in the code possibly?

Code:
mysql_query("update users set pwd='$newmd5' where `id`='$_SESSION[user_id]',
			`full_name` = '$_POST[name]',
			`address` = '$_POST[address]',
			`tel` = '$_POST[tel]',
			`fax` = '$_POST[fax]',
			`website` = '$_POST[web]',
			 WHERE id='$_SESSION[user_id]'
			") or die(mysql_error());
Im not sure though?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 12:30 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Webmasterpals.com (c) 2008 - All Rights Reserved