Jump to content


Photo

Snippet Editor - HOW TO!?!?


  • Please log in to reply
29 replies to this topic

#21 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 11:13 AM

This is roughly how it look like
<?php
// MySQL Connection
$host = "localhost";
$username = "root";
$password = "";
$db = "database";
mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());

$id = $_GET['id'];
if (isset($id))
{
	$query = "SELECT * FROM members WHERE id='$id'";
    $result = mysql_query($query) or die("There's some problem with the query.");
    $row = mysql_fetch_assoc($result);
	if (!isset($_POST['submit']))
    {
?>

<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<table align="center" border="0" cellspacing="0" cellpadding="3">
<tr><td>Name</td><td><input type="text" name="name" value="<?php echo $row['name']; ?>" maxlength="30"></td></tr>
<tr><td>Location</td><td><input type="text" name="location" value="<?php echo $row['location']; ?>" maxlength="30"></td></tr>
<tr><td>Age</td><td><input type="text" name="age" value="<?php echo $row['age']; ?>" maxlength="30"></td></tr>
<tr><td><input type="submit" value="Submit" name="submit"><td></tr>
</table>
</form>

<?php
	}
    else
    {
	$name = $_POST['name'];
    $location = $_POST['location'];
    $age = $_POST['age'];
    mysql_query("UPDATE `members` SET `name` = '$name', `location` = '$location', `age` = '$age' WHERE id = '$id'");
    echo "Profile updated !";
    }
}
?>


Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#22 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 11:15 AM

Ok ,but I dont need to use a database to edit their profiles, im doing it now... except with one giant <textarea> that edits their whole page, i want textboxes that edit little snippets.
Link shortener with advanced, detailed statistics:

http://tyny.us/

#23 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 11:16 AM

If you stored their informations inside database, then you need to update the database to make any changes.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#24 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 11:16 AM

OMG i get it. lol ;) youre telling me how to update their information, like password and email and stuff, but thats not what im after! LMAO.
Link shortener with advanced, detailed statistics:

http://tyny.us/

#25 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 30 July 2006 - 11:17 AM

What exactly are you after then?

#26 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 11:20 AM

Ok, Ill try to be clear. :)

OK .. do you use myspace? a profile editor like that.. multiple text boxes that writes information to a page.. ..i really dont know how else to say it.
Link shortener with advanced, detailed statistics:

http://tyny.us/

#27 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 30 July 2006 - 11:28 AM

Ah, I see what you mean. Regardless, I am pretty sure you are going to have to store the information in a database. What you could do is to make another table with all the fields your going to have in the profile editor. Make one field named tag or something like that. Then on your profile edit/add page, have the users id inserted into the tag field. That way the information of those fields is unique to that user. Then call it where tag=$id . Then go from there (making sure no one else can view someone elses profile by chaning the id etc). Not sure if this is the best way to go about it though. Hopefully someone with more knowledge of php will post a better method.

#28 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 11:33 AM

Yeah, I dont know how to do that sruff!! HAHA LMAO, Im new to PHP. well im about 2 mos into it... :P
Link shortener with advanced, detailed statistics:

http://tyny.us/

#29 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 11:34 AM

Well i G2G, ill be on l8r....
Link shortener with advanced, detailed statistics:

http://tyny.us/

#30 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 11:36 AM

Same here, I'm going off.
So if you still have any problems just post here. :)

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users