Connecting Tech Pros Worldwide Forums | Help | Site Map

problem in redirecting the page

omerbutt's Avatar
Needs Regular Fix
 
Join Date: Nov 2006
Location: Earth Obviously :P
Posts: 344
#1: Apr 1 '08
hi there i a making a community page where i am editing the details for the communities added in the favourities of the user the, i am using html ajax javascript,php and mysql.Now the problem is that when i edit the details of any particular community the form submits the information is sent on another page "communityeditdone.php"but from that page it does not go to the desired location and stays on that page. the code for the form and the page on which the info is submitted is here
file name:form.php
Expand|Select|Wrap|Line Numbers
  1. <tr>
  2. <td align="left" valign="top" width="497">
  3. <form name="add" id="add" action="communityeditdone.php" method="post" enctype="multipart/form-data" onsubmit="return checkEditCommunity();">
  4. <table cellspacing="0" cellpadding="2" border="0" align="left" width="497">
  5. <? if($msg){
  6. echo "
  7. <tr>
  8. <td align=\"left\" colspan='2' class=\"bgcolor_gray3 text_yellow_12\">$msg <a href='communities.php?nlt5qk4sewitr9slhv=$linkset' class='text_yellow_link'>Click Here</a> to go back to Community Page
  9. </td>
  10. </tr>";
  11. }?>
  12. <tr><td align="right" width="146" class="bgcolor_gray2 text_yellow_12">* Name : </td>
  13. <td align="left" width="200" class="bgcolor_gray2"><input name="community_name" id="community_name" type="text" class="textfield" maxlength="18" value="<?=$com_name?>" /><input type="hidden" name="co_id" id="co_id" value="<?=$com_id?>" /></td>
  14. </tr>
  15. <tr>
  16. <td align="right" class="text_yellow_12 bgcolor_gray3">* Category : </td>
  17. <td align="left" class="bgcolor_gray3">
  18. <select name="community_category" id="community_category" size="1" style="width: 250px;">
  19. <option value="nothing" selected="selected">Choose</option>
  20. <?
  21. $category_array= $mycategories->ShowCommunities();
  22. foreach ($category_array as $k=>$v){                                        if($com_info['community_category_id']==$k){
  23.         echo "<option value=$k selected=selected>$v</option>\n";
  24.     }else{
  25.     echo "<option value=$k>$v</option>\n";
  26.     }
  27. }
  28. ?>
  29. </select>
  30. </td>
  31. </tr>
  32. <tr>
  33. <td align="right" class="bgcolor_gray2 text_yellow_12">* Image : </td>
  34. <td align="left" class="bgcolor_gray2"><input name="community_group_pic" id="community_group_pic" type="file" /> <a href="javascript: myWin('<?=$img;?>')" class="text_yellow_link">View Picture</a></td>
  35. </tr>
  36. <tr><td align="right" valign="top" class="bgcolor_gray3 text_yellow_12">* Description : </td>
  37. <td align="left" class="bgcolor_gray3"><textarea name="community_group_description" id="community_group_description" rows="5" class="textarea" wrap="physical"><?=$com_desc;?></textarea></td>
  38. </tr>
  39. <tr>
  40. <td align="right" valign="top" class="bgcolor_gray2">&nbsp;</td>
  41. <td align="left" class="bgcolor_gray2"><input name="cancel" type="button" class="button" id="cancel" value="Cancel" title="Cancel" onclick="window.location.replace('communitydetails.php?com_id=<?=$com_id;?>')"/>&nbsp;<input name="Submit" id="Submit" type="submit" class="button" title="Update" value="Update" /></td>
  42. </tr>
  43. </table>
  44. </form>
  45. </td>
  46. </tr>
  47.  
file name:communityedit.php
Expand|Select|Wrap|Line Numbers
  1. <?
  2.     include("includes/config.php");
  3.     include("includes/thumbnail.class.php");
  4.     $member_id = $_SESSION['SESSION_member_id'];
  5.     if(isset($_POST["Submit"])){
  6.         $co_id = $_POST['co_id'];
  7.         $com_group_name = $_POST['community_name'];
  8.         $com_group_description = $_POST['community_group_description'];
  9.         if($_FILES['community_group_pic']['name']!=""){
  10.             $query = "select community_group_pic_path, community_group_pic_path_small from ".PREFIX."community_groups where community_group_id='$co_id'";
  11.             $rec = mysql_query($query);
  12.             $image = mysql_fetch_array($rec);
  13.             @unlink($image['community_group_pic_path']);
  14.             @unlink($image['community_group_pic_path_small']);
  15.             $path = "photos/community/".time().'_'.$_FILES['community_group_pic']['name'];
  16.             $path_small = "photos/community/small/".time().'_'.$_FILES['community_group_pic']['name'];
  17.             move_uploaded_file($_FILES['community_group_pic']['tmp_name'],$path);
  18.             $imagesmall = new Thumbnail($path, 145, 145, 80);
  19.             $imagesmall->save($path);
  20.             $imageful = new Thumbnail($path, 85, 85, 80);
  21.             $imageful->save($path_small);
  22.         }
  23.         if($_FILES['community_group_pic']['name']==""){
  24.             $query = "select community_group_pic_path, community_group_pic_path_small from ".PREFIX."community_groups where community_group_id='$co_id'";
  25.             $rec = mysql_query($query);
  26.             $image = mysql_fetch_array($rec);
  27.             $path = $image['community_group_pic_path'];
  28.             $path_small = $image['community_group_pic_path_small'];
  29.         }
  30.         $qUpdate = "update ".PREFIX."community_groups set 
  31.                 community_group_name = '$com_group_name',
  32.                 member_id = '$member_id',
  33.                 community_group_pic_path = '$path',
  34.                 community_group_pic_path_small = '$path_small',
  35.                 community_group_description = '$com_group_description',
  36.                 community_group_stamp = ".time()." where community_group_id=$co_id";
  37.         $rUpdate = execute($qUpdate);
  38.     }
  39.     header("Location:communitydetails.php");
  40.     exit();
  41. ?>
  42.  

TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#2: Apr 1 '08

re: problem in redirecting the page


I don't understand? The form I believe is working as sending the user input to communityedit.php should appear as though no other page is loaded, but rather just refreshes the form (and possibly a bit more from that page).

If you want to test if it is running, check if the communityedit.php functions have been run, or just include an echo ("This is working"); somewhere in the communityedit.php.

My apologies if I have misunderstood, I read it a few time and am still confused what exactly the problem is.
omerbutt's Avatar
Needs Regular Fix
 
Join Date: Nov 2006
Location: Earth Obviously :P
Posts: 344
#3: Apr 1 '08

re: problem in redirecting the page


Quote:

Originally Posted by TheServant

I don't understand? The form I believe is working as sending the user input to communityedit.php should appear as though no other page is loaded, but rather just refreshes the form (and possibly a bit more from that page).

If you want to test if it is running, check if the communityedit.php functions have been run, or just include an echo ("This is working"); somewhere in the communityedit.php.

My apologies if I have misunderstood, I read it a few time and am still confused what exactly the problem is.

hey thanks for replying ,i already did that
it is doing everything perfectly,even that it is updates teh record also but the only thing which is not working is the
<? header("location: community.php")?> :(
any sugesstions ,
reagrds ,
omer
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#4: Apr 1 '08

re: problem in redirecting the page


Quote:

Originally Posted by omerbutt

hey thanks for replying ,i already did that
it is doing everything perfectly,even that it is updates teh record also but the only thing which is not working is the
<? header("location: community.php")?> :(
any sugesstions ,
reagrds ,
omer

Does it come up with headers already sent error? I searched for <? header("location: community.php")?> and you do not have that part of your code there. Please include it.
omerbutt's Avatar
Needs Regular Fix
 
Join Date: Nov 2006
Location: Earth Obviously :P
Posts: 344
#5: Apr 1 '08

re: problem in redirecting the page


Quote:

Originally Posted by TheServant

Does it come up with headers already sent error? I searched for <? header("location: community.php")?> and you do not have that part of your code there. Please include it.

soory for that it is actually
header("location:communitydetails.php"); the very last line in the communityedit page
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#6: Apr 1 '08

re: problem in redirecting the page


Quote:

Originally Posted by omerbutt

soory for that it is actually
header("location:communitydetails.php"); the very last line in the communityedit page

Oh yeah. I am not sure if that exit() straight after it is causing issues. Actually struggling with a similar problem at the moment with one of my forms. I have got a semi working solution where a variable at the end of the equivalent communityedit.php script is set like: "form_submitted = TRUE; return()" and then on the form.php you only display the form if form_submitted = NULL or FALSE, otherwise, show [HTML]<meta http-equiv=\"refresh\" content=\"0;url=communitydetails.php\">[/HTML]

Didn't work exactly how I wanted, but you might use it.
omerbutt's Avatar
Needs Regular Fix
 
Join Date: Nov 2006
Location: Earth Obviously :P
Posts: 344
#7: Apr 1 '08

re: problem in redirecting the page


Quote:

Originally Posted by TheServant

Oh yeah. I am not sure if that exit() straight after it is causing issues. Actually struggling with a similar problem at the moment with one of my forms. I have got a semi working solution where a variable at the end of the equivalent communityedit.php script is set like: "form_submitted = TRUE; return()" and then on the form.php you only display the form if form_submitted = NULL or FALSE, otherwise, show [HTML]<meta http-equiv=\"refresh\" content=\"0;url=communitydetails.php\">[/HTML]

Didn't work exactly how I wanted, but you might use it.

hey i didnt get what u are trying to say :(, where should i use this thing
"form_submitted = TRUE; return()"
on the communityedit.php page or where and that header
Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv=\"refresh\" content=\"0;url=communitydetails.php\">
  2.  
should set it on the page where i havemade the form ?
hey sorry if i am bothering you but i really didnt get what you are trying to say
reagrds,
omer
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#8: Apr 1 '08

re: problem in redirecting the page


Quote:

Originally Posted by TheServant

Oh yeah. I am not sure if that exit() straight after it is causing issues. Actually struggling with a similar problem at the moment with one of my forms. I have got a semi working solution where a variable at the end of the equivalent communityedit.php script is set like: "form_submitted = TRUE; return()" and then on the form.php you only display the form if form_submitted = NULL or FALSE, otherwise, show [HTML]<meta http-equiv=\"refresh\" content=\"0;url=communitydetails.php\">[/HTML]

Didn't work exactly how I wanted, but you might use it.

exit();
Should indeed be called after you redirect, as the script doesn't stop after the redirect - it goes through to the end of the script.

@The OP: Have you tried using a direct URL? (http://...)?

Regards.
omerbutt's Avatar
Needs Regular Fix
 
Join Date: Nov 2006
Location: Earth Obviously :P
Posts: 344
#9: Apr 1 '08

re: problem in redirecting the page


Quote:

Originally Posted by markusn00b

exit();
Should indeed be called after you redirect, as the script doesn't stop after the redirect - it goes through to the end of the script.

@The OP: Have you tried using a direct URL? (http://...)?

Regards.

hey thanks alot
the realitive path method worked for me i added the meta tag that you old and rermoved the header(location:communitiesdetail.php) and added the
exit(); after that
and it is working abosolutely perfect,
hey thanks alooooooooooooots budyyy
regards,
omer aslam
Reply