Jump to content

[SOLVED] Removing something from code


supermerc

Recommended Posts

Hey, I have a code to edit profile, and the code used to have a field to be able to change email but I removed it, but Im not able to remove it completely now when I try to edit profile it says your email was empty and not in email formate, so I removed the error echos but then I was getting other errors, so I put it back, if anyone could help me because i dont know what I have to remove in order for it to work again.

 

this is my code

 

echo 

"

<style>

body

{

background: #ffffff;

font-family: Verdana, Arial;

font-weight: bold;

font-size: 9px;

color: #000000;

}

.register_box

{

border: 1px solid #323232;

background: #202020;

font-family: Verdana, Arial;

font-weight: bold;

font-size: 9px;

color: #FFFFFF;

}

</style>

";

if(isset($_SESSION['s_logged_n']))

{

$session_username = $_SESSION['s_username'];

// further checking...

if(username_exists($session_username))

{

$get_info = mysql_query("SELECT description FROM users WHERE username = '$session_username' LIMIT 1");

if(mysql_num_rows($get_info) > 0)

{

$user_info = mysql_fetch_assoc($get_info);

if(!isset($_POST['do_edit']))

{

echo '

<form action="edit_profile.php" method="post">'

?>

<?php

echo'<p>Description:

</br>

<textarea name="textfield" cols="45" rows="5">' . $user_info['description'] . '</textarea>

<br/>

<br>

Click <a href="picupload.php">here</a> to edit your profile picture.

<br/>

<b><br/>

<input type="submit" name="do_edit" value="Edit Your Profile" />

</form>

<b><br/>

<b><br/>

<b>*Note that if you change your email to an invalid email you will not be able to receive emails to change your password etc.<br/>

';

}

elseif(isset($_POST['do_edit']))

{

$email = mysql_real_escape_string($_POST['email']);

// assign all errors to an array

$errors = array();

if(empty($email))

{

$errors[] = 'Your email was empty.';

}

if(!is_valid_email($email))

{

$errors[] = 'Your email was not in a valid email format.';

}

// if array elements is greater than 0,

// then we KNOW there was an error

// else, no error, move on to processing

if(count($errors) > 0)

{

echo '<b>ERRORS:</b><br />';

foreach($errors as $err)

{

echo $err . '<br />';

}

}

else

{

// everything is ok, update the DB

mysql_query("UPDATE users SET description = '" . $_POST['description'] . "' WHERE username = '$session_username'");

echo 'Profile Edited.';

}

}

}

else

{

echo 'Could not find profile info for your username.';

}

}

else

{

echo 'Sorry, your session username doesnt exist.';

}

}

else

{

echo 'You must be logged in to edit your profile.';

}

?>

 

thanks

Link to comment
Share on other sites

It's not enough to simply remove the echos, you must remove the validation if statements that cause the echos to be displayed.

 

Try this:

 

echo 

"

<style>

body

{

background: #ffffff;

font-family: Verdana, Arial;

font-weight: bold;

font-size: 9px;

color: #000000;

}

.register_box

{

border: 1px solid #323232;

background: #202020;

font-family: Verdana, Arial;

font-weight: bold;

font-size: 9px;

color: #FFFFFF;

}

</style>

";

if(isset($_SESSION['s_logged_n']))

{

$session_username = $_SESSION['s_username'];

// further checking...

if(username_exists($session_username))

{

$get_info = mysql_query("SELECT description FROM users WHERE username = '$session_username' LIMIT 1");

if(mysql_num_rows($get_info) > 0)

{

$user_info = mysql_fetch_assoc($get_info);

if(!isset($_POST['do_edit']))

{

echo '

<form action="edit_profile.php" method="post">'

?>

<?php

echo'<p>Description:

</br>

<textarea name="textfield" cols="45" rows="5">' . $user_info['description'] . '</textarea>

<br/>

<br>

Click <a href="picupload.php">here</a> to edit your profile picture.

<br/>

<b><br/>

<input type="submit" name="do_edit" value="Edit Your Profile" />

</form>

<b><br/>

<b><br/>

<b>*Note that if you change your email to an invalid email you will not be able to receive emails to change your password etc.<br/>

';

}

elseif(isset($_POST['do_edit']))

{


// if array elements is greater than 0,

// then we KNOW there was an error

// else, no error, move on to processing

if(count($errors) > 0)

{

echo '<b>ERRORS:</b><br />';

foreach($errors as $err)

{

echo $err . '<br />';

}

}

else

{

// everything is ok, update the DB

mysql_query("UPDATE users SET description = '" . $_POST['description'] . "' WHERE username = '$session_username'");

echo 'Profile Edited.';

}

}

}

else

{

echo 'Could not find profile info for your username.';

}

}

else

{

echo 'Sorry, your session username doesnt exist.';

}

}

else

{

echo 'You must be logged in to edit your profile.';

}

?>

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.