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
Share on other sites

You also have two single quotes in front of ''$about'...

 

 

Should be ...

 

"UPDATE pilots SET about = '$about'

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

 

and

 

"UPDATE pilots SET semail = '$semail'

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

 

Link to comment
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']}'";

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.