Jump to content

Need Some Help On Index Redirecting


astonishin

Recommended Posts

It's called $_GET

http://www.w3schools.com/php/php_get.asp

 

Get variables are visible and can be retrieved from the address bar.

Usually a form is used, but also works without a form.

 

Alternately $_POST is commonly used and requires some sort of form. The values are not visible in the address bar.

http://www.tizag.com/phpT/forms.php

 

You may use $_POST ,$_GET among other types..

http://php.net/manual/en/reserved.variables.php

... depending on what you need to do.

 

What you use the variable for is almost limited just by your imagination.

You can include a php page for instance.

http://www.tizag.com/phpT/include.php

 

As for your question:

$os = $_GET['os'];
if(isset($_GET['os']) && $os == "learn") (
include('how.php');
)

 

if/else or switch statements could show different results depending on the value of any different $_GET or $os value

http://www.w3schools.com/php/php_if_else.asp

http://www.tizag.com/phpT/switch.php

 

May also use the variable to fetch different results from mysql

http://www.w3schools.com/php/php_mysql_select.asp

 

 

Read the tutorials, try them, any more questions or problems can always ask for more help here.

The php manual has lots of good information and many times contains excellent examples.

http://php.net/manual/en/manual.php

Link to comment
Share on other sites

How can i implement it with whats below? Sorry for double posting

 

$home    = "";
$how     = "";
$signup  = "";
$offers  = "";
$friends = "";
$login   = "";
$register = "";


if ($page == "home") {
    $home = "current_page_item";
} else if ($page == "how") {
    $how = "curren_page_item";
} else if ($page == "signup") {
    $signup = "current_page_item";
} else if ($page == "offers") {
    $offers = "current_page_item";
} else if ($page == "friends") {
    $friends = "current";
} else if ($page == "login") {
    $login = "current_page_item";
} else if ($page == "register") {
    $register == "current_page_item";
}

Link to comment
Share on other sites

I knew you knew.

 

It's not really incorrect, as else if still works as long as is brackets, but elseif is also faster.

 

I was actually thinking of what the original poster really wants.

 

It may be wiser to actually do header redirects and then include a header.php file each page along with a navigation menu.

Link to comment
Share on other sites

I implemented this on this page and it doesn't work

the site is mucove.com also when the index page loads how can i make it go to mucove.com/?os=home

<?
session_start();
global $ui,$count;
$page = "offers";
include "assets/includes/connect.php";
include "assets/includes/config.php";


if ($_SESSION['loggedin']!='1') {
echo "Please <a href='login.php'>Login</a> or <a href='../members/register.php'>Register</a> to view this page.<br>
You will be redirected to <a href='login.php'>Login</a> page after 3 seconds.";
echo "<meta http-equiv=\"refresh\" content=\"3;url=../?os=register\"></center>";
} else {
if ($_GET['action']=='complete') {
	$query = "SELECT * FROM `pending` WHERE offer_id='".mysql_real_escape_string($_GET['oid'])."' AND user_id='".$ui['id']."'";
	$result = mysql_query($query) or die(mysql_error());
	if (mysql_num_rows($result)>0) {
		print "<center>You already submited this offer.<br>Please return to <a href='?os=offers'>Offers</a> page and submit another offer.</center>";
		exit;
	} else {
		$date = date("F j, Y, g:i a");
		$getoffer = "SELECT * FROM `offers` WHERE id='".mysql_real_escape_string($_GET['oid'])."'";
		$result = mysql_query($getoffer) or die(mysql_error());
		$offer = mysql_fetch_array($result);
		$query = "INSERT INTO `pending` VALUES('','".$offer['id']."','".$ui['id']."','".$date."','".$offer['reward']."','1')";
		mysql_query($query) or die(mysql_error());
		print "<center>Offer moved to pending list. Please allow it up to 3 days to get approved.<br>Complete more <a href='../?os=offers'>Offers</a></center>";
		exit;
	}		
} else {
	if ($_GET['action']=='list') {
		print "<table width=\"100%\">
		<tr>
		<td>Name</td>
		<td>Reward</td>
		<td>Status</td>
		</tr>";
		$getpend = "SELECT * FROM `pending` WHERE user_id='".$ui['id']."'";
		$pend = mysql_query($getpend) or die(mysql_error());
		$getcomp = "SELECT * FROM `completed` WHERE user_id='".$ui['id']."'";
		$comp = mysql_query($getcomp) or die(mysql_error());
		if ((mysql_num_rows($pend)==0) && (mysql_num_rows($comp)==0)) {
			print"<center>You don't have any pending or denied offers, Please go to <a href='?os=offers'>Offers</a> page to submit any offer by your choice and get reward for it.</center>";
		} else {
			if (mysql_num_rows($comp)>0) {
				while ($completed = mysql_fetch_array($comp)) {
					$getoffer = "SELECT * FROM offers WHERE id='".$completed['offer_id']."'";
					$offer = mysql_query($getoffer) or die(mysql_error());
					if (mysql_num_rows($offer)==0) {
						continue;
					} else {
						$offer = mysql_fetch_array($offer);
						print"
						<tr>
						<td>".$offer['name']."</td>
						<td>".$offer['reward']."</td>
						<td><font color=green>Completed</font></td>
						</tr>";
					}
				}	
			}
			if (mysql_num_rows($pend)>0) {
				while ($pending = mysql_fetch_array($pend)) {
					$getoffer = "SELECT * FROM offers WHERE id='".$pending['offer_id']."'";
					$offer = mysql_query($getoffer) or die(mysql_error());
					if (mysql_num_rows($offer)==0) {
						continue;
					} else {
						$offer = mysql_fetch_array($offer);
						if ($pending['status']==1) { $status='<font color=red>Pending</font>'; }
						if ($pending['status']==2) { $status='<font color=#72a3eb>Denied</font>'; }
						print"
						<tr>
						<td>".$offer['name']."</td>
						<td>".$offer['reward']."</td>
						<td>".$status."</td>
						</tr>";
					}
				}	
			}				
		}
		print "</table>";
		print"<br><center>Back to <a href='../?os=offer'>offer</a> page.</center>";
		exit;
	}
}
print "<center>View <a href='?action=list'>Denied, Pending and Completed</a> offer list.<br><br>";
print "<center>Please select offer type.</center>";
$query = "SELECT * FROM `offer_types` WHERE active=1";
$result = mysql_query($query) or die(mysql_error());
print "<center>";
while ( $otypes = mysql_fetch_array($result)) {
	print" | <a href='?os=offers?type=".$otypes['id']."'>".$otypes['type']."</a> | ";
}
print "</center><br>";
if ($_GET['type']) {
	$query = "SELECT * FROM `offers` WHERE active=1 AND type='".mysql_real_escape_string($_GET['type'])."' ORDER BY `reward` DESC";
} else {
	$query = "SELECT * FROM `offers` WHERE active=1 ORDER BY `reward` DESC";
}
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result)==0) {
	print "<center>No Offers available at the moment, please check other sections for different offer types.</center>";
} else {
	print "<table width=\"100%\">
	<tr>
	<td>Name</td>
	<td>Description</td>
	<td>Countries</td>
	<td>Reward</td>
	<td>Action</td>
	</tr>";
	while ( $offer = mysql_fetch_array($result)) {
		$getcompleted = "SELECT * FROM `completed` WHERE offer_id='".$offer['id']."' AND user_id='".$ui['id']."'";
		$completed = mysql_query($getcompleted) or die(mysql_error());
		if (mysql_num_rows($completed)>0) {
			continue;
		} else {
			$getpending = "SELECT * FROM `pending` WHERE offer_id='".$offer['id']."' AND user_id='".$ui['id']."'";
			$pending = mysql_query($getpending) or die(mysql_error());
			if (mysql_num_rows($pending)==0) {
				$link = "<form method=GET><input type=hidden name=action value=complete><input type=hidden name=oid value='".$offer['id']."'><input type=submit value='Submit'></form>";
			} else {
				$pend=mysql_fetch_array($pending);
				if ($pend['status']==1) { $link = "<font color=red>Pending</font>"; }
				if ($pend['status']==2) { $link = "<font color=#72a3eb>Denied</font>"; }
			}
			print "
			<tr>
			<td><a href='".$offer['url']."' target=_blank>".$offer['name']."</a></td>
			<td>".$offer['info']."</td>
			<td>".$offer['country']."</td>
			<td>".$offer['reward']."</td>
			<td>".$link."</td>
			</tr>";
		}
	}
}
print "</table>";
}




?>

Link to comment
Share on other sites

You can place somethinglike this before the if/else

 

if(!isset($_GET['os']) || $_GET['os'] == "") {
$page = "home";
}

 

You can also in your if/else do a last else including home.php

 

$page = $_GET['os'];

if ($page == "home") {
    include('home.php');
} elseif ($page == "how") {
    include('how.php');
} elseif ($page == "signup") {
    include('signup.php');
} elseif ($page == "offers") {
    include('offers.php');
} elseif ($page == "friends") {
    include('friends.php');
} elseif ($page == "login") {
    include('login.php');
} elseif ($page == "register") {
    include('register.php');
} else {
    include('home.php');
}

Link to comment
Share on other sites

can i pay you to implement this for me?

 

I added this to my site and change the urls from pagename.php to ?os=pagename but some parts of the script needs to run an action after pagename.php?action=complete&oid=416 how can i do this with the script?

Link to comment
Share on other sites

using a switch statement would be better than that long if .. elseif statement. it also has a default setting for when the value of $page isn't found, which can be used to redirect to a 'page not found' page or index/whatever.

 

 

Can you please start me off?

Link to comment
Share on other sites

<?php
switch ($page) {
    case 'how':
        include('how.php');
        break;
    case 'why':
        include('why.php');
        break;
    
    default:
      include('index.php');
}
?>

in this example if $page's value isn't listed it will do default at the bottom

taken from http://php.net/manual/en/control-structures.switch.php and adapted slightly to your stuff

Link to comment
Share on other sites

Thanks im about to add that to my site mucove.com can you please tell me out i can implement this with a page that also calls for other actions like i have my offers.php page and when you click the submit button it goes to a blank page calling ?action=completed

Link to comment
Share on other sites

<?php
switch ($page) {
    case 'how':
        include('how.php');
        break;
    case 'why':
        include('why.php');
        break;
    
    default:
      include('index.php');
}
?>

in this example if $page's value isn't listed it will do default at the bottom

taken from http://php.net/manual/en/control-structures.switch.php and adapted slightly to your stuff

 

ahh it doesnt work and what im trying to achieve is some thing like ?os=learn taking members to a how.php page

Link to comment
Share on other sites

Just to elaborate some more some of the files are like below.

 

<?
switch ($_GET['do']) {
    case 'passchange2':
        do_pass_change();
        break;
    default:
        pass_change();
        break;
}
function pass_change()
{
    global $ui, $c, $userid, $h;
    print "<center><h4>To change your password, please fill out the information below.<br></h4><form action='?os=changepass?do=passchange2' method='post'>
<table><tr><td>
Current Password:</td><td><input type='password' name='oldpw' /></td></tr>
<tr><td>New Password:</td><td><input type='password' name='newpw' /></td></tr>
<tr><td>Confirm:</td><td><input type='password' name='newpw2' /></td></tr>
<Tr><td colspan=2 align=center>
<input type='submit' class='button' value='Change Your Password' /></form></td></tr></table></center>";
}
function do_pass_change()
{
    global $ui, $c, $userid, $h;
    if (md5($_POST['oldpw']) != $ui['userpass']) {
        print "The current password you entered was wrong.<br />
<a href='?os=changepass?do=passchange'>> Back</a>";
    } else if ($_POST['newpw'] !== $_POST['newpw2']) {
        print "The new passwords you entered did not match!<br />
<a href='?os=changepass?do=passchange'>> Back</a>";
    } else {
        $_POST['oldpw'] = strip_tags($_POST['oldpw']);
        $_POST['newpw'] = strip_tags($_POST['newpw']);
        mysql_query("UPDATE users SET userpass=md5('{$_POST['newpw']}') WHERE id={$_SESSION['userid']}", $c);
        print "Password changed!<br>The next time you log in you will need to use your new password.";
    }
}
?>

 

So if i use what they told me above and go to http://mucove.com/?os=changepass then try to change the pass it would try to do something like http://mucove.com/?os=changepass?do=passchange2 to change password but that doesn't work it just shows a blank page.

 

Test the website with the username:test and pass:simpletest

Link to comment
Share on other sites

Just to elaborate some more some of the files are like below.

 

<?
switch ($_GET['do']) {
    case 'passchange2':
        do_pass_change();
        break;
    default:
        pass_change();
        break;
}
function pass_change()
{
    global $ui, $c, $userid, $h;
    print "<center><h4>To change your password, please fill out the information below.<br></h4><form action='?os=changepass?do=passchange2' method='post'>
<table><tr><td>
Current Password:</td><td><input type='password' name='oldpw' /></td></tr>
<tr><td>New Password:</td><td><input type='password' name='newpw' /></td></tr>
<tr><td>Confirm:</td><td><input type='password' name='newpw2' /></td></tr>
<Tr><td colspan=2 align=center>
<input type='submit' class='button' value='Change Your Password' /></form></td></tr></table></center>";
}
function do_pass_change()
{
    global $ui, $c, $userid, $h;
    if (md5($_POST['oldpw']) != $ui['userpass']) {
        print "The current password you entered was wrong.<br />
<a href='?os=changepass?do=passchange'>> Back</a>";
    } else if ($_POST['newpw'] !== $_POST['newpw2']) {
        print "The new passwords you entered did not match!<br />
<a href='?os=changepass?do=passchange'>> Back</a>";
    } else {
        $_POST['oldpw'] = strip_tags($_POST['oldpw']);
        $_POST['newpw'] = strip_tags($_POST['newpw']);
        mysql_query("UPDATE users SET userpass=md5('{$_POST['newpw']}') WHERE id={$_SESSION['userid']}", $c);
        print "Password changed!<br>The next time you log in you will need to use your new password.";
    }
}
?>

 

So if i use what they told me above and go to http://mucove.com/?os=changepass then try to change the pass it would try to do something like http://mucove.com/?os=changepass?do=passchange2 to change password but that doesn't work it just shows a blank page.

 

Test the website with the username:test and pass:simpletest

 

Is the code you posted contained in the page "http://mucove.com/?os=changepass"?

 

Just as an example (you do NOT have to change the code to what I have, just checking I'm understanding you correctly), here's the way I have a site set-up.

 

if($_GET['page']=="aboutus"){
include 'aboutus.php';
$section="- About Us";
}
elseif($_GET['page']=="contactus"){
include 'contactus.php';
$section="- Contact Us";
}

 

In my contactus.php page I have:

 

if($_GET['do']=="showform"){
include 'contactform.php';
$section="- Contact Form";
}
ect...
else{
}

Now I can get an URL of www.domainname.ext/index.php?page=contactus&do=showform

Link to comment
Share on other sites

Below is the code for one of my pages

 

if ($_SESSION['loggedin']!='1') {
echo "Please <a href='login.php'>Login</a> or <a href='members/regster.php'>Register</a> to view this page.<br>
You will be redirected to <a href='members/login.php'>Login</a> page after 3 seconds.";
echo "<meta http-equiv=\"refresh\" content=\"3;url=members/register.php\"></center>";
} else {
if ($_GET['action']=='complete') {
	$query = "SELECT * FROM `pending` WHERE offer_id='".mysql_real_escape_string($_GET['oid'])."' AND user_id='".$ui['id']."'";
	$result = mysql_query($query) or die(mysql_error());
	if (mysql_num_rows($result)>0) {
		print "<center>You already submited this offer.<br>Please return to <a href='offers.php'>Offers</a> page and submit another offer.</center>";
		exit;
	} else {
		$date = date("F j, Y, g:i a");
		$getoffer = "SELECT * FROM `offers` WHERE id='".mysql_real_escape_string($_GET['oid'])."'";
		$result = mysql_query($getoffer) or die(mysql_error());
		$offer = mysql_fetch_array($result);
		$query = "INSERT INTO `pending` VALUES('','".$offer['id']."','".$ui['id']."','".$date."','".$offer['reward']."','1')";
		mysql_query($query) or die(mysql_error());
		print "<center>Offer moved to pending list. Please allow it up to 3 days to get approved.<br>Complete more <a href='../offers.php'>Offers</a></center>";
		exit;
	}		
} else {
	if ($_GET['action']=='list') {
		print "<table width=\"100%\">
		<tr>
		<td>Name</td>
		<td>Reward</td>
		<td>Status</td>
		</tr>";
		$getpend = "SELECT * FROM `pending` WHERE user_id='".$ui['id']."'";
		$pend = mysql_query($getpend) or die(mysql_error());
		$getcomp = "SELECT * FROM `completed` WHERE user_id='".$ui['id']."'";
		$comp = mysql_query($getcomp) or die(mysql_error());
		if ((mysql_num_rows($pend)==0) && (mysql_num_rows($comp)==0)) {
			print"<center>You don't have any pending or denied offers, Please go to <a href='offers.php'>Offers</a> page to submit any offer by your choice and get reward for it.</center>";
		} else {
			if (mysql_num_rows($comp)>0) {
				while ($completed = mysql_fetch_array($comp)) {
					$getoffer = "SELECT * FROM offers WHERE id='".$completed['offer_id']."'";
					$offer = mysql_query($getoffer) or die(mysql_error());
					if (mysql_num_rows($offer)==0) {
						continue;
					} else {
						$offer = mysql_fetch_array($offer);
						print"
						<tr>
						<td>".$offer['name']."</td>
						<td>".$offer['reward']."</td>
						<td><font color=green>Completed</font></td>
						</tr>";
					}
				}	
			}
			if (mysql_num_rows($pend)>0) {
				while ($pending = mysql_fetch_array($pend)) {
					$getoffer = "SELECT * FROM offers WHERE id='".$pending['offer_id']."'";
					$offer = mysql_query($getoffer) or die(mysql_error());
					if (mysql_num_rows($offer)==0) {
						continue;
					} else {
						$offer = mysql_fetch_array($offer);
						if ($pending['status']==1) { $status='<font color=red>Pending</font>'; }
						if ($pending['status']==2) { $status='<font color=#72a3eb>Denied</font>'; }
						print"
						<tr>
						<td>".$offer['name']."</td>
						<td>".$offer['reward']."</td>
						<td>".$status."</td>
						</tr>";
					}
				}	
			}				
		}
		print "</table>";
		print"<br><center>Back to <a href='../?os=home'>offer</a> page.</center>";
		exit;
	}
}
print "<center>View <a href='?action=list'>Denied, Pending and Completed</a> offer list.<br><br>";
print "<center>Please select offer type.</center>";
$query = "SELECT * FROM `offer_types` WHERE active=1";
$result = mysql_query($query) or die(mysql_error());
print "<center>";
while ( $otypes = mysql_fetch_array($result)) {
	print" | <a href='offers.php?type=".$otypes['id']."'>".$otypes['type']."</a> | ";
}
print "</center><br>";
if ($_GET['type']) {
	$query = "SELECT * FROM `offers` WHERE active=1 AND type='".mysql_real_escape_string($_GET['type'])."' ORDER BY `reward` DESC";
} else {
	$query = "SELECT * FROM `offers` WHERE active=1 ORDER BY `reward` DESC";
}
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result)==0) {
	print "<center>No Offers available at the moment, please check other sections for different offer types.</center>";
} else {
	print "<table width=\"100%\">
	<tr>
	<td>Name</td>
	<td>Description</td>
	<td>Countries</td>
	<td>Reward</td>
	<td>Action</td>
	</tr>";
	while ( $offer = mysql_fetch_array($result)) {
		$getcompleted = "SELECT * FROM `completed` WHERE offer_id='".$offer['id']."' AND user_id='".$ui['id']."'";
		$completed = mysql_query($getcompleted) or die(mysql_error());
		if (mysql_num_rows($completed)>0) {
			continue;
		} else {
			$getpending = "SELECT * FROM `pending` WHERE offer_id='".$offer['id']."' AND user_id='".$ui['id']."'";
			$pending = mysql_query($getpending) or die(mysql_error());
			if (mysql_num_rows($pending)==0) {
				$link = "<form method=GET><input type=hidden name=action value=complete><input type=hidden name=oid value='".$offer['id']."'><input type=submit value='Submit'></form>";
			} else {
				$pend=mysql_fetch_array($pending);
				if ($pend['status']==1) { $link = "<font color=red>Pending</font>"; }
				if ($pend['status']==2) { $link = "<font color=#72a3eb>Denied</font>"; }
			}
			print "
			<tr>
			<td><a href='".$offer['url']."' target=_blank>".$offer['name']."</a></td>
			<td>".$offer['info']."</td>
			<td>".$offer['country']."</td>
			<td>".$offer['reward']."</td>
			<td>".$link."</td>
			</tr>";
		}
	}
}
print "</table>";
}




?>

 

when someone press the submit button it goes to ?action=complete&oid=411 how can i make it go to ?os=offers&action=complete&oid=411

Link to comment
Share on other sites

Below is the code for one of my pages

 

if ($_SESSION['loggedin']!='1') {
echo "Please <a href='login.php'>Login</a> or <a href='members/regster.php'>Register</a> to view this page.<br>
You will be redirected to <a href='members/login.php'>Login</a> page after 3 seconds.";
echo "<meta http-equiv=\"refresh\" content=\"3;url=members/register.php\"></center>";
} else {
if ($_GET['action']=='complete') {
	$query = "SELECT * FROM `pending` WHERE offer_id='".mysql_real_escape_string($_GET['oid'])."' AND user_id='".$ui['id']."'";
	$result = mysql_query($query) or die(mysql_error());
	if (mysql_num_rows($result)>0) {
		print "<center>You already submited this offer.<br>Please return to <a href='offers.php'>Offers</a> page and submit another offer.</center>";
		exit;
	} else {
		$date = date("F j, Y, g:i a");
		$getoffer = "SELECT * FROM `offers` WHERE id='".mysql_real_escape_string($_GET['oid'])."'";
		$result = mysql_query($getoffer) or die(mysql_error());
		$offer = mysql_fetch_array($result);
		$query = "INSERT INTO `pending` VALUES('','".$offer['id']."','".$ui['id']."','".$date."','".$offer['reward']."','1')";
		mysql_query($query) or die(mysql_error());
		print "<center>Offer moved to pending list. Please allow it up to 3 days to get approved.<br>Complete more <a href='../offers.php'>Offers</a></center>";
		exit;
	}		
} else {
	if ($_GET['action']=='list') {
		print "<table width=\"100%\">
		<tr>
		<td>Name</td>
		<td>Reward</td>
		<td>Status</td>
		</tr>";
		$getpend = "SELECT * FROM `pending` WHERE user_id='".$ui['id']."'";
		$pend = mysql_query($getpend) or die(mysql_error());
		$getcomp = "SELECT * FROM `completed` WHERE user_id='".$ui['id']."'";
		$comp = mysql_query($getcomp) or die(mysql_error());
		if ((mysql_num_rows($pend)==0) && (mysql_num_rows($comp)==0)) {
			print"<center>You don't have any pending or denied offers, Please go to <a href='offers.php'>Offers</a> page to submit any offer by your choice and get reward for it.</center>";
		} else {
			if (mysql_num_rows($comp)>0) {
				while ($completed = mysql_fetch_array($comp)) {
					$getoffer = "SELECT * FROM offers WHERE id='".$completed['offer_id']."'";
					$offer = mysql_query($getoffer) or die(mysql_error());
					if (mysql_num_rows($offer)==0) {
						continue;
					} else {
						$offer = mysql_fetch_array($offer);
						print"
						<tr>
						<td>".$offer['name']."</td>
						<td>".$offer['reward']."</td>
						<td><font color=green>Completed</font></td>
						</tr>";
					}
				}	
			}
			if (mysql_num_rows($pend)>0) {
				while ($pending = mysql_fetch_array($pend)) {
					$getoffer = "SELECT * FROM offers WHERE id='".$pending['offer_id']."'";
					$offer = mysql_query($getoffer) or die(mysql_error());
					if (mysql_num_rows($offer)==0) {
						continue;
					} else {
						$offer = mysql_fetch_array($offer);
						if ($pending['status']==1) { $status='<font color=red>Pending</font>'; }
						if ($pending['status']==2) { $status='<font color=#72a3eb>Denied</font>'; }
						print"
						<tr>
						<td>".$offer['name']."</td>
						<td>".$offer['reward']."</td>
						<td>".$status."</td>
						</tr>";
					}
				}	
			}				
		}
		print "</table>";
		print"<br><center>Back to <a href='../?os=home'>offer</a> page.</center>";
		exit;
	}
}
print "<center>View <a href='?action=list'>Denied, Pending and Completed</a> offer list.<br><br>";
print "<center>Please select offer type.</center>";
$query = "SELECT * FROM `offer_types` WHERE active=1";
$result = mysql_query($query) or die(mysql_error());
print "<center>";
while ( $otypes = mysql_fetch_array($result)) {
	print" | <a href='offers.php?type=".$otypes['id']."'>".$otypes['type']."</a> | ";
}
print "</center><br>";
if ($_GET['type']) {
	$query = "SELECT * FROM `offers` WHERE active=1 AND type='".mysql_real_escape_string($_GET['type'])."' ORDER BY `reward` DESC";
} else {
	$query = "SELECT * FROM `offers` WHERE active=1 ORDER BY `reward` DESC";
}
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result)==0) {
	print "<center>No Offers available at the moment, please check other sections for different offer types.</center>";
} else {
	print "<table width=\"100%\">
	<tr>
	<td>Name</td>
	<td>Description</td>
	<td>Countries</td>
	<td>Reward</td>
	<td>Action</td>
	</tr>";
	while ( $offer = mysql_fetch_array($result)) {
		$getcompleted = "SELECT * FROM `completed` WHERE offer_id='".$offer['id']."' AND user_id='".$ui['id']."'";
		$completed = mysql_query($getcompleted) or die(mysql_error());
		if (mysql_num_rows($completed)>0) {
			continue;
		} else {
			$getpending = "SELECT * FROM `pending` WHERE offer_id='".$offer['id']."' AND user_id='".$ui['id']."'";
			$pending = mysql_query($getpending) or die(mysql_error());
			if (mysql_num_rows($pending)==0) {
				$link = "<form method=GET><input type=hidden name=action value=complete><input type=hidden name=oid value='".$offer['id']."'><input type=submit value='Submit'></form>";
			} else {
				$pend=mysql_fetch_array($pending);
				if ($pend['status']==1) { $link = "<font color=red>Pending</font>"; }
				if ($pend['status']==2) { $link = "<font color=#72a3eb>Denied</font>"; }
			}
			print "
			<tr>
			<td><a href='".$offer['url']."' target=_blank>".$offer['name']."</a></td>
			<td>".$offer['info']."</td>
			<td>".$offer['country']."</td>
			<td>".$offer['reward']."</td>
			<td>".$link."</td>
			</tr>";
		}
	}
}
print "</table>";
}




?>

 

when someone press the submit button it goes to ?action=complete&oid=411 how can i make it go to ?os=offers&action=complete&oid=411

 

You have to wrap your current code in an if statement that has $_GET['os']=="offers" as it's condition. And change your form action="" to match.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.