Jump to content

No Errors No Updating


topflight

Recommended Posts

Hi all,

  May somebody please help me, I am trying to create an update profile script it works(i think becuase I am not receiving any syntax errors) but, nothing displays or the database doesn't update.

here is my code

 

<?php
if(!$_COOKIE['login'])
{
header("Location:login.php");
}
?>
<?php
if(isset($_GET['login'])){

$email = $_POST['email'];
$semail = $_POST['semail'];
$pwd = $_POST['pwd'];
$about = $_POST['about'];

if((!$email) || (!$pwd)){
echo '<font color="#FF0000"><center>The following Required Data is Missing</font></center>'; 

if(!$email){
echo'You have left the Email filed empty. Please enter a valid email';

}


if(!$pwd){
echo 'You have left the Password Filed empty. Please enter a password';

} else { 

include 'db.php';

$sql = "SELECT * FROM pilots WHERE login = '{$_GET['login']}'";
$query = mysql_query($sql) or die("Problem with the query: $sql<br>" . mysql_error()); 
$query = mysql_query($sql); 

if($query){
$erow = mysql_num_rows($query);

if($erow >= 1){
echo'The Email Address you have chosen is already in the database'; 
} else {


$update1 = "UPDATE pilots SET email = '$email''
          WHERE login = '{$_GET['login']}'";
$result1 = mysql_query($update1) or die (mysql_error());



$update2 = "UPDATE pilots SET pwd = '$pwd'
           WHERE login = '{$_GET['login']}'";
$result2 = mysql_query($update2) or die (mysql_error());




$update3 = "UPDATE pilots SET about = ''$about'
           WHERE login = '{$_GET['login']}'";
$result3 = mysql_query($update3) or die (mysql_error());



$update4 = "UPDATE pilots SET semail = ''$semail'
           WHERE login = '{$_GET['login']}'";
$result4 = mysql_query($update4) or die (mysql_error());?>

<script>javascript:alert("Account Updated" )</script>
<script>javascript:window.location = "index.php"</script> <?php
}

}

   } 
   } 
   
   }
?>

 

thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/131346-no-errors-no-updating/
Share on other sites

Still just showing a white page. Not updating or running the javascript with using the following code:

 

 

"UPDATE pilots SET about = '$about'

          WHERE login = '{$_GET['login']}'";

 

and

 

"UPDATE pilots SET semail = '$semail'

          WHERE login = '{$_GET['login']}'";

Time for a re-write:

<?php
if(!$_COOKIE['login'])
{
header("Location:login.php");
}
if(isset($_GET['login'])){
$errors = array();
$qtmp = array();
foreach ($_POST as $fld => $val) {
	$val = trim(stripslashes($val));
	switch ($fld) {
		case 'email':
			if (strlen($val) == 0)
				$errors[] = 'You have left the Email filed empty. Please enter a valid email';
			else
				$qtmp[] = $fld . " = '" . mysql_real_escape_string($val) . "'";
			break;
		case 'pwd':
			if (strlen($val) == 0)
				$errors[] = 'You have left the Password Filed empty. Please enter a password';
			else
				$qtmp[] = $fld . " = '" . mysql_real_escape_string($val) . "'";
			break;
		case 'semail':
		case 'about':
			if (strlen($val) > 0)
				$qtmp[] = $fld . " = '" . mysql_real_escape_string($val) . "'";
			break;
	}
}
if (!empty($errors)) {
	echo '<p style="color:red;text-align:center">The following Required Data is Missing</p>';
	echo implode("<br>\n",$errors) . "<br>\n";
} else {
	include 'db.php';

	$sql = "SELECT * FROM pilots WHERE login = '" . mysql_real_escape_string(stripslashes($_GET['login'])) . "'";
	$query = mysql_query($sql) or die("Problem with the query: $sql<br>" . mysql_error()); 
	$erow = mysql_num_rows($query);
	if($erow > 0){
		echo 'The Email Address you have chosen is already in the database'; 
	} else {
		if (!empty($qtmp)) {
			$uq = 'update pilots set ' . implode(', ', $qtmp) . " WHERE login = '" . mysql_real_escape_string(stripslashes($_GET['login'])) . "'";
			$rs = mysql_query($uq) or die("Problem with the update query: $uq<br>" . mysql_error());
			echo '<script>alert("Account Updated" );
					window.location = "xindex.php"</script>';
		}
	}
   } 
}
?>

 

I combined the error checking with creating a temporary array to create the update query. Also, your Javascript was incorrect. You don't need "Javascript:" when inside the <script> tag.

 

Ken

I have now got errors to show and now I am receiving the follow error.

 

Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\editp_phrase.php on line 10

 

this is my code

<?php
if(!$_COOKIE['login'])
{
header("Location:login.php");
}
?>
<?php 
E_ALL

if(isset($_GET['login'])){

$email = $_POST['email'];
$semail = $_POST['semail'];
$pwd = $_POST['pwd'];
$about = $_POST['about'];

if((!$email) || (!$pwd)){
echo '<font color="#FF0000"><center>The following Required Data is Missing</font></center>'; 

if(!$email){
echo'You have left the Email filed empty. Please enter a valid email';

}


if(!$pwd){
echo 'You have left the Password Filed empty. Please enter a password';

} else { 

include 'db.php';

$sql = "SELECT * FROM pilots WHERE login = '{$_GET['login']}'";
$query = mysql_query($sql) or die("Problem with the query: $sql<br>" . mysql_error()); 
$query = mysql_query($sql); 

if($query){
$erow = mysql_num_rows($query);

if($erow >= 1){
echo'The Email Address you have chosen is already in the database'; 
} else {


"UPDATE pilots SET semail = '$semail', email = '$email', $about = '$about', $pwd = '$pwd' WHERE login = '{$_GET['login']}'";?>





<script>javascript:alert("Account Updated" )</script>
<script>javascript:window.location = "index.php"</script> <?php
}

}

   } 
   } 
   
   }
?>

this is line 10

<?php if(isset($_GET['login'])){

 

Please give advice thanks a lot in advanced.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.