wiggly81 Posted August 13, 2008 Share Posted August 13, 2008 Hi all, i hope you will be able to help me, i am very new to PHP and have stumbled on a problem with a profile page i am writing. i have the page called from the member area as profile.php?act=view&id=1 depending if the profile is being viewed or edited it says view or edit (basics) and ofcause you will see the id is called from the MySQL database... now the problem i have is when i type the url and leave the ?act=*&id=* i get a page of errors. i would like this page to say somthing along the lines of "You Have Reached This Page In Error!" This is the basic code so far most likly there is better ways to do things that the ways i have but as i said i am learning. <?PHP // profile.php include('include/head.php'); include('include/pro_var.php'); confirm_logged_in(); if ($_SESSION['level'] == 0) { redirect('index.php'); } $profile = "SELECT * FROM users WHERE id = ".$_GET['id'].""; $result = mysql_query($profile); while($rows = mysql_fetch_array($result)) { ?> <table width="70%" align="center" class="table"> <tr> <td colspan="2" class="td2"> <h2><?PHP echo $rows['user']; ?></h2> </td> </tr> </tr> <td colspan="2" class="td2"> <?PHP if ($_GET['act'] == 'edit') { echo "{$edit_pro}"; }elseif ($_GET['act'] == 'view') { echo "{$view_pro}"; } ?> </td> </tr> <tr> <td colspan="2" class="td2"> <?PHP if ($_GET['act'] == 'view') { if ($_SESSION['user_id'] == $_GET['id']) { echo "<a href=profile.php?act=edit&&id=".$_GET['id'].">Edit Profile</a>"; }else { echo ""; } }elseif ($_GET['act'] == 'edit') { echo "<a href=profile.php?act=view&&id=".$_GET['id'].">View Profile</a>"; }else { echo ""; } ?> </td> </tr> </table> <?PHP } mysql_close(); include('include/foot.php'); ?> Thank You In Advance Wiggly Quote Link to comment https://forums.phpfreaks.com/topic/119545-help-_getact/ Share on other sites More sharing options...
Barand Posted August 13, 2008 Share Posted August 13, 2008 Post in the correct forum. This is NOT a maths question. Quote Link to comment https://forums.phpfreaks.com/topic/119545-help-_getact/#findComment-615863 Share on other sites More sharing options...
wildteen88 Posted August 13, 2008 Share Posted August 13, 2008 now the problem i have is when i type the url and leave the ?act=*&id=* i get a page of errors. i would like this page to say somthing along the lines of "You Have Reached This Page In Error!" That's because you should always check to see if user defined variables exist first before using them. Eg if((isset($_GET['act']) && $_GET['act'] == 'view') && (isset($_GET['id']) && is_numeric($_GET['id'])) { // variables are set, your code here } // variables are not set, display error else { die('You Have Reached This Page In Error!'); } Quote Link to comment https://forums.phpfreaks.com/topic/119545-help-_getact/#findComment-615874 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.