473,686 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting and using current page URL

7 New Member
Hie

could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as follows:

The code below is for the first page:session_st art is in line 3

<link href="css/jobSheet.css" rel="stylesheet " type="text/css" />
[php]
session_start() ;
[/php]

<html>
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
-->
</style><head>
<link href="CalendarC ontrol.css" rel="stylesheet " type="text/css"><script src="CalendarCo ntrol.js" language="javas cript"></script>

<script type="text/javascript" language="javas cript">
function validate()
{
var passMsg = "\n!!!Incor rect password!!!";
var msg = "You are required to complete the following fields:";
var status = true;
var date = document.oldCli ents.todays_dat e.value;
var dateArray = date.split("-");
var newDateArray = new Array(3)
var year = dateArray[2];
var day = dateArray[1];
var month = dateArray[0]-1;
newDateArray[0]=year;
newDateArray[1]=day;
newDateArray[2]=month;
var myDate = new Date;
myDate.setDate( day);
myDate.setMonth (month);
myDate.setFullY ear(year);

var today = new Date;
/* regDate = /^\d{1,2}\-\d{1,2}\-\d{4}$/;
var regWord =/^[A-Za-z]+$/;
regAlnum = /^[\w ]+$/;
regNum =/^\d+$/;
regEmail =/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;
regWeb =/^(([w]{3})+(\.[_a-z0-9-]+)+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/
//alert(myDate); */
if(document.old Clients.firstNa me.value == "")
{
msg += "\n - First name";
status = false;
}

if(document.old Clients.lastNam e.value == "")
{
msg += "\n - Last name";
status = false;
}

if(document.old Clients.clientT itle.value == "")
{
msg += "\n - Client Title";
status = false;
}

if(document.old Clients.company _name.value == "")
{
msg += "\n - Company Name";
status = false;
}

if(document.old Clients.company _code.value == "")
{
msg += "\n - Company code";
status = false;
}

if(document.old Clients.Site_ad dress.value == "")
{
msg += "\n - Site Address";
status = false;
}

if(document.old Clients.postal_ address.value == "")
{
msg += "\n - Postal Address";
status = false;
}

if(document.old Clients.phone_n umber.value == "")
{
msg += "\n - Phone Number";
status = false;
}

if(document.old Clients.email_a ddress.value == "")
{
msg += "\n - Email Address";
status = false;
}
if(document.old Clients.website .value == "")
{
msg += "\n - Website";
status = false;
}


if(document.old Clients.assigne dStaff.options. selectedIndex == 0)
{
msg += "\n - Assigned Staff";
status = false;
}

if ((myDate < today)||(date== ""))
{
msg +="\n -Invalid date";
status = false;
}


if(document.old Clients.status. options.selecte dIndex == 0)
{
msg += "\n - Status";
status = false;
}

if(document.old Clients.title.v alue == "")
{
msg += "\n - Job title";
status = false;
}

if(document.old Clients.textare a.value == "")
{
msg += "\n - Request";
status = false;
}

if(status != true)
{

alert(msg);
return(0);

}
else
{
document.oldCli ents.submit();
}

}
</script>
</head>
<body>
[php]
require_once('d bFunction.php') ;

function curPageURL() {
//$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_POR T"] != "80") {
// $pageURL .= $_SERVER["SERVER_NAM E"].":".$_SERVE R["SERVER_POR T"].$_SERVER["REQUEST_UR I"];
} else {
$pageURL .=$_SERVER["REQUEST_UR I"];
$_SESSION['pageURL'] = $pageURL;
}
return $pageURL;
}

[/php]

<form name="oldClient s" method="post" action="dbNewCl ientJobsheet.ph p">
[php]
dbConnect();

$role = mysql_query("SE LECT * FROM STATUS_DESC") or die(mysql_error ());
$staff = mysql_query("SE LECT * FROM STAFF")
[/php]

<table width="75%" cellpadding="5" cellspacing="0" class="borderTo p" align="center" height="60%">
<td colspan="2" bgcolor="#FFCC0 0" align="center"> <strong>New Client Jobsheet</strong></td>
<tr>

<td align="left" width="65%" valign="top">
<table align="left" width="100%" cellpadding="5" cellspacing="0" >

<tr align="center" class="formHead er">
<td width="47%" bgcolor="#FFCC0 0"><strong>Clie nt details</strong>
<td width="53%" bgcolor="#FFCC0 0"><strong>J ob sheet details</strong> </td>
</tr>
<tr>
<td valign="top" align="center">

<table cellpadding="4" class="formText ">
<tr><td>First name*<td><input name="firstName " type="text" class="input"/></td>
<tr><td>Last name*<td><input name="lastName" type="text" class="input" id="lastName"/></td>
<tr><td>Clien t Title<td><input type="text" name="clientTit le" class="input"></td>
<tr><td>Compa ny name<td><input type="text" name="company_n ame" class="input"></td>
<tr><td>Compa ny code<td><input type="text" name="company_c ode" class="input"></td>
<tr><td>Site address<td><inp ut name="Site_addr ess" type="text" class="input" /></td>
<tr><td>Posta l address<td><inp ut name="postal_ad dress" type="text" class="input" /></td>
<tr><td>Phone number<td><inpu t type="text" name="phone_num ber" class="input"></td>
<tr><td>E-mail*<td><input type="text" name="email_add ress" class="input"></td>
<tr><td>Website <td><input type="text" name="website" class="input"></td>
</tr>
</table>
<td valign="top" align="center">

<table cellpadding="3" >
<tr><td class="formText ">Job Sheet Number<td class="formText ">
[php]
echo JobIdGen();
[/php]
</td>
<tr><td class="formText ">Date<td class="formText "><?php echo date("l, j F Y"); ?></td>
<tr><td class="formText ">Assigned to*<td>
<select name="assignedS taff">
<option value="0">Choos e one*</option>
[php]
while($staffRow = mysql_fetch_arr ay($staff))
{
echo '<option value='.$staffR ow['staffID'].'>'.$staffRow['username'].'</option>';
}
[/php]
</select>

<tr><td class="formText ">Assigned Date*<td>
<input name="todays_da te" onFocus="showCa lendarControl(t his);" type="text">

<tr><td class="formText ">Assigned Time*<td>
<?php //<input name="assigned_ time" type= "text" id= "assigned_t ime" class="textArea Border">
?>
<select name="postHour" ><option value="1"> 1 </option><option selected="selec ted" value ="2"> 2 </option> <option value="3"> 3 </option> <option value="4"> 4 </option> <option value="5"> 5 </option> <option value="6"> 6 </option> <option value="7"> 7 </option> <option value="8"> 8 </option> <option value="9"> 9 </option> <option value="10"> 10 </option> <option value="11"> 11 </option> <option value="12"> 12 </option> </select> : <select name="postMinut e"><option value="00"> 00 </option> <option value="15"> 15 </option> <option value="30"> 30 </option> <option value="45"> 45 </option> </select> <select name="postAMPM" > <option value="0"> AM </option> <option selected="selec ted" value="1"> PM </option> </select>

</td>
<tr><td class="formText ">Time Created<td class="formText ">
<?php echo strftime("%R",t ime());
echo ' Hours';
?>

</td>
</tr>
<tr><td>Status* <td>
<select name="status">
<option value="0">Choos e one</option>
<?php
while($row = mysql_fetch_arr ay($role))
{
echo '<option value='.$row['status_desc_ID '].'>'.$row['status_type'].'</option>';
}
?>
</select>
</td>
</table>
<tr><td></td></tr>
<tr>
<td colspan="2" align="center" class="borderTo p" bgcolor="#FFCC0 0"><span class="formHead er"> <strong>Request </strong></span></td></tr>
<tr>
<td colspan="2" align="center" class="borderTo p" bgcolor="#FFCC0 0"><span class="formHead er">
<strong>Title * :<input name="title" type="text" class="input"/></strong></span></td></tr>
<tr>
<td colspan="2" align="center"> <textarea name="textarea" cols="70" rows="10" class="textArea Border"><?php
echo "The current page name is ".curPageUR L();
?></textarea></td></tr>
<tr>
<tr><td colspan="2" align="center" class="borderTo p" bgcolor="#FFCC0 0">
<input type="button" name="clear" value="Clear" class="button" >
<input class="button" type="button" value="Submit" onClick="valida te();">

</td></tr>
</table>
</td>
</tr>

</table>
</td>
</tr>
</table>

</form>

the second page is where the fuction to redirect is and thats where i am getting things mixed up:

[PHP]
session_start() ;

function dbConnect()
{
if(!mysql_pconn ect(xxxx,xxxx,x xxxx))
{
"Can not connect to the database!";
exit();
}
mysql_select_db ("casiac_gto ");
}


//check if the variable is numeric
function nukeNum($value, $pageURL) {
$value3 = trim(stripslash es($value));
$num =((strlen($valu e3) == 0) or (!ereg("^[[:digit:]- ]{1,100}$",$valu e3)));
if(!$num){
header('Locatio n: $pageURL');
}else{
return $value3;
}
}

//checks if variable contains alpha-numeric characters
function nukeAlphaNum($v alue,$pageURL) {
$value4 = trim(stripslash es($value));
$num =((strlen($valu e4) == 0) or (!ereg("^[[:alnum:]/-,. ]{1,100}$",$valu e4)));
if(!$num){
header('Locatio n: $pageURL');
}else{
return $value4;
}
}

function isEmail($value, $pageURL) {
$email = trim(stripslash es($value));
$num = ((strlen($email ) == 0) or (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$email )));
if(!$num){
header('Locatio n: $pageURL');
}else{
return $value4;
}

};

[/PHP]

I reckon the second piece of code is the most important and code someone please give me a hand

thank you
May 8 '07 #1
1 3193
Purple
404 Recognized Expert Contributor
Hi simbarashe,

I think you are building the uri incorrectly - I haven't tried to recreate it but I offer the following which works for me..

[PHP]$uri = "//" . $_SERVER["SERVER_NAM E"]. rtrim(dirname($ _SERVER['PHP_SELF']), '/\\'); // build the URI for redirect to login screen
header("Locatio n: http:".$uri."/play.php");[/PHP]

so subsitute play.php for the page you are trying to fire - obviously don't output anything to the screen (including whitespace) before the header redirect..

Hope this helps..
May 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
331
by: Leonard Rutkowski | last post by:
I am using a third party product that requires a reference to a page, Me.Page for example. I would like to use this product in a function, in a vb class, that I am writing. I know that I can pass the page, as an object, into the method, but I was wondering if there was a way to get the current page, inside a vb class, using a .NET method. Thanks, Leonard
4
5970
by: Nick | last post by:
I'm developing an intranet app, and want to get the current user name for logging purposes. I've turned off anonymous access, and turned on windows authentication in the IIS config. The apps web.config file has authentication mode set to windows, and 'identity impersonate' is set to true. When I try and get the default.aspx page, IE returns an error page with an 'Access is denied.' error. (Even if I try direct from the webserver, logged...
3
3081
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are displayed. Can anybody know this issue and help me to resolve this. In past i received the response saying that i should download the image first and then parse the actual response and modify the src attribute of the
1
1410
by: Nathan Sokalski | last post by:
I have retrieved data from a database using a SELECT statement that includes an INNER JOIN. The data seems to be retrieved to the DataSet OK, but I am having trouble getting the data from the DataSet. The code I am using is as follows: Private Sub btnDownloadDB_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnDownloadDB.Click Dim papdatabase As New DataSet Dim cmdSelect As New...
4
13611
by: Pat | last post by:
In my Web.config i have :- <customErrors mode="On" defaultRedirect="genericerror.htm"> <error statusCode="404" redirect="pagenotfound.aspx"/> </customErrors to get page not found error but instead i keep getting a RUN TIME error below: Any ideas.. Runtime Error
8
8500
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there a way to get it from a static method in an aspx page, or in the class (static) constructor for an aspx page? Thanks, Bryan
8
7070
by: BB | last post by:
Hi, I am using FormView Contol, TextBox (Hidden ) and Submit button whose caption is "View Page" in my aspx page. Here is what I am tryin to do.When page loads I generate dynamic url in text box . I want to append exisitng value in Formview field "CustomeID" to url. When userclicks on "view page" ,new window is opened with dynamic url. I am able to do generarting url dynamically, but dont know how i can do rest of the things. Any idea?
3
1920
by: Norman Wooten | last post by:
Ok, I am a nOOb C#/NET coder, so this is probably easy.. heh heh (only been pecking is these languages for a week now, just converted from vbscript and classic asp) But anyways, I have a class library - and wish to be able to determine the currently loaded theme for the calling webpage programaticly.. I can do this in the code-behind using page.theme - but can not in the class library (for whatever small reason I am missing).. Hope I...
3
9547
by: tshad | last post by:
I have a file that I converted from VB.Net to C# that works fine in VB.Net when I compile but not in C# using the same libraries. The error I am getting is: PageInit.cs(9,7): error CS0138: A using namespace directive can only be applied to namespaces; 'System.Web.HttpCookie' is a class not a namespace The code is:
0
8586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8520
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8936
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7603
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6442
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.