/    Sign up×
Community /Pin to ProfileBookmark

Help with Passign session array Thru links

I need to separate the form in the following code and make it as a stand along file itself but still have the function of the arrays working. I am new to php and have no clue how to achieve that.

The goal is to pass the page1.html of $referurl[1] via link one, page2.html of $referurl[2] via link two and so on while using the same form. (i.e. 5 links in one page that links to the same form but passing different value to the same field in the form).

Thanks.

[code=php]
<?php

session_start();

$pagenum = $_GET[‘refpage’];

// defined the page urls to refer
$referurl[1] = ‘page1.html;
$referurl[2] = ‘page2.html’;
$referurl[3] = ‘page3.html’;
$referurl[4] = ‘page4.html’;
$referurl[5] = ‘page5.html’;

$thisurl = ‘http://’.$_SERVER[‘HTTP_HOST’].ltrim($_SERVER[‘PHP_SELF’], ‘/’);
$refurl = ‘http://’.$_SERVER[‘HTTP_HOST’].’/’.$referurl[$pagenum];

?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title></title>
</head>
<body>
<!– BEGING CODE FOR REFER –>
<a href=”#” rel=”lightbox1″ title=”Refer <?=$pagetitle[1]?> to a friend!” class=”lbOn”>Refer <?=$pagetitle[1]?> to a friend!</a><br />
<a href=”#” rel=”lightbox2″ title=”Refer <?=$pagetitle[2]?> to a friend!” class=”lbOn”>Refer <?=$pagetitle[2]?> to a friend!</a><br />
<a href=”#” rel=”lightbox3″ title=”Refer <?=$pagetitle[3]?> to a friend!” class=”lbOn”>Refer <?=$pagetitle[3]?> to a friend!</a><br />
<a href=”#” rel=”lightbox4″ title=”Refer <?=$pagetitle[4]?> to a friend!” class=”lbOn”>Refer <?=$pagetitle[4]?> to a friend!</a><br />
<a href=”#” rel=”lightbox5″ title=”Refer <?=$pagetitle[5]?> to a friend!” class=”lbOn”>Refer <?=$pagetitle[5]?> to a friend!</a><br />
<?php
for($i=1;$i<=5;$i++)
{
?>
<div id=”lightbox<?=$i?>” class=”leightbox”>
<form name=”refer” id=”refer” action=”referproc.php” method=”post” onsubmit=”return validateOnSubmit()”>
<fieldset id=”refertofriend” style=”width: auto;”>
<legend>Refer <?=$pagetitle[$i]?> to a friend!</legend>
<table border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td class=”fieldlabel”>Friend’s name</td>
<td class=”fieldinput”><input name=”friendsname” type=”text” value=”” />
<br /><div id=”errorfname”> </div></td>
</tr>
<tr>
<td class=”fieldlabel”>Friend’s email</td>
<td class=”fieldinput”><input name=”friendsemail” type=”text” value=”” />
<br /><div id=”errorfemail”> </div></td>
</tr>
<tr>
<td class=”fieldlabel”>Your name</td>
<td class=”fieldinput”><input name=”yourname” type=”text” value=”” />
<br /><div id=”erroryname”> </div></td>
</tr>
<tr>
<td class=”fieldlabel”>Your email</td>
<td class=”fieldinput”><input name=”youremail” type=”text” value=”” />
<br /><div id=”erroryemail”> </div></td>
</tr>
<tr>
<td class=”fieldlabel”>Message</td>
<td class=”fieldinput”><textarea name=”message” cols=”30″ rows=”6″ ></textarea>
<br /><div id=”errormsg”> </div><br /></td>
</tr>
<tr>
<td class=”fieldlabel”>Copy to self?</td>
<td class=”fieldinput”><input name=”copy” type=”checkbox” value=”1″ />
<br /><div id=”erroryemail”> </div></td>
</tr>
<tr>
<td colspan=”2″ align=”center”><br /><input type=”submit” name=”submit” value=”submit” /></td>
</tr>
</table>
</fieldset>
<input type=”hidden” name=”pagename” value=”<?=$pagetitle[$i]?>” />
<input type=”hidden” name=”refurl” value=”<?php echo ‘http://’,$_SERVER[‘HTTP_HOST’],’/’,$referurl[$i]; ?>” />
</form>
<p class=”footer”>
<a href=”#” class=”lbAction” rel=”deactivate”>Close</a>
</p>
</div>
<!– END ERREFER CODE –>
<?php
} // end for statment
?></body>
</html>

[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @phpnewbie08 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...