problem in redirecting the page  | Needs Regular Fix | | Join Date: Nov 2006 Location: Earth Obviously :P
Posts: 344
| |
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 -
<tr>
-
<td align="left" valign="top" width="497">
-
<form name="add" id="add" action="communityeditdone.php" method="post" enctype="multipart/form-data" onsubmit="return checkEditCommunity();">
-
<table cellspacing="0" cellpadding="2" border="0" align="left" width="497">
-
<? if($msg){
-
echo "
-
<tr>
-
<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
-
</td>
-
</tr>";
-
}?>
-
<tr><td align="right" width="146" class="bgcolor_gray2 text_yellow_12">* Name : </td>
-
<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>
-
</tr>
-
<tr>
-
<td align="right" class="text_yellow_12 bgcolor_gray3">* Category : </td>
-
<td align="left" class="bgcolor_gray3">
-
<select name="community_category" id="community_category" size="1" style="width: 250px;">
-
<option value="nothing" selected="selected">Choose</option>
-
<?
-
$category_array= $mycategories->ShowCommunities();
-
foreach ($category_array as $k=>$v){ if($com_info['community_category_id']==$k){
-
echo "<option value=$k selected=selected>$v</option>\n";
-
}else{
-
echo "<option value=$k>$v</option>\n";
-
}
-
}
-
?>
-
</select>
-
</td>
-
</tr>
-
<tr>
-
<td align="right" class="bgcolor_gray2 text_yellow_12">* Image : </td>
-
<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>
-
</tr>
-
<tr><td align="right" valign="top" class="bgcolor_gray3 text_yellow_12">* Description : </td>
-
<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>
-
</tr>
-
<tr>
-
<td align="right" valign="top" class="bgcolor_gray2"> </td>
-
<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;?>')"/> <input name="Submit" id="Submit" type="submit" class="button" title="Update" value="Update" /></td>
-
</tr>
-
</table>
-
</form>
-
</td>
-
</tr>
-
file name:communityedit.php -
<?
-
include("includes/config.php");
-
include("includes/thumbnail.class.php");
-
$member_id = $_SESSION['SESSION_member_id'];
-
if(isset($_POST["Submit"])){
-
$co_id = $_POST['co_id'];
-
$com_group_name = $_POST['community_name'];
-
$com_group_description = $_POST['community_group_description'];
-
if($_FILES['community_group_pic']['name']!=""){
-
$query = "select community_group_pic_path, community_group_pic_path_small from ".PREFIX."community_groups where community_group_id='$co_id'";
-
$rec = mysql_query($query);
-
$image = mysql_fetch_array($rec);
-
@unlink($image['community_group_pic_path']);
-
@unlink($image['community_group_pic_path_small']);
-
$path = "photos/community/".time().'_'.$_FILES['community_group_pic']['name'];
-
$path_small = "photos/community/small/".time().'_'.$_FILES['community_group_pic']['name'];
-
move_uploaded_file($_FILES['community_group_pic']['tmp_name'],$path);
-
$imagesmall = new Thumbnail($path, 145, 145, 80);
-
$imagesmall->save($path);
-
$imageful = new Thumbnail($path, 85, 85, 80);
-
$imageful->save($path_small);
-
}
-
if($_FILES['community_group_pic']['name']==""){
-
$query = "select community_group_pic_path, community_group_pic_path_small from ".PREFIX."community_groups where community_group_id='$co_id'";
-
$rec = mysql_query($query);
-
$image = mysql_fetch_array($rec);
-
$path = $image['community_group_pic_path'];
-
$path_small = $image['community_group_pic_path_small'];
-
}
-
$qUpdate = "update ".PREFIX."community_groups set
-
community_group_name = '$com_group_name',
-
member_id = '$member_id',
-
community_group_pic_path = '$path',
-
community_group_pic_path_small = '$path_small',
-
community_group_description = '$com_group_description',
-
community_group_stamp = ".time()." where community_group_id=$co_id";
-
$rUpdate = execute($qUpdate);
-
}
-
header("Location:communitydetails.php");
-
exit();
-
?>
-
|  | Expert | | Join Date: Feb 2008 Location: Australia
Posts: 914
| | | 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.
|  | Needs Regular Fix | | Join Date: Nov 2006 Location: Earth Obviously :P
Posts: 344
| | | 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
|  | Expert | | Join Date: Feb 2008 Location: Australia
Posts: 914
| | | 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.
|  | Needs Regular Fix | | Join Date: Nov 2006 Location: Earth Obviously :P
Posts: 344
| | | 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
|  | Expert | | Join Date: Feb 2008 Location: Australia
Posts: 914
| | | 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.
|  | Needs Regular Fix | | Join Date: Nov 2006 Location: Earth Obviously :P
Posts: 344
| | | 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 -
<meta http-equiv=\"refresh\" content=\"0;url=communitydetails.php\">
-
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
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,949
| | | 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.
|  | Needs Regular Fix | | Join Date: Nov 2006 Location: Earth Obviously :P
Posts: 344
| | | 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
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|