This topic is locked

User details

3/11/2007 5:12:57 PM
PHPRunner General questions
P
paddywills author

I would like a user to be able to edit their profile. Therefore I need to bypass the "List" view and go straight to "Edit" view. Is there a way to set this up?

J
Jane 3/12/2007

Hi,
you can do it using ListOnLoad event on the Events tab.

Here is a sample:

function ListOnLoad()

{

//select ID of logged user

global $conn;

$str = "select * from UsersTable where UserName='".$_SESSION["UserID"]."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
//redirect to the Edit page

?><script>

window.location='./users_edit.php?editid1=<?php echo $data["IDField"]?>';

</script><?php

exit();

}



where UsersTable is your actual table name, UserName and IDField are your actual field names.

L
Lorenbond 10/10/2008

Using the classified template I was able to make this work with a couple of mods.
//select ID of logged user

global $conn;

$str = "select * from register where username='".$_SESSION["UserID"]."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
// redirect to the Edit page

?><script>
window.location='./MyProfile_edit.php?editid1=<?php echo $data["password"]?>&editid2=<?php echo $data["username"]?>';
</script><?php

exit();

L
Lorenbond 10/29/2008

Using the classified template I was able to make this work with a couple of mods.

//select ID of logged user

global $conn;

$str = "select * from register where username='".$_SESSION["UserID"]."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
// redirect to the Edit page

?><script>
window.location='./MyProfile_edit.php?editid1=<?php echo $data["password"]?>&editid2=<?php echo $data["username"]?>';
</script><?php

exit();


This worked great in version 4.2 but after I upgraded to version 5 it no longer works. The list page loads but does not redirect to the edit page. Is there additional coding required for version 5?

Sergey Kornilov admin 10/30/2008

You need to go to HTML source of the page to see what code it generates. This way you can tell if redirect code is correct.