Jump to content

Recommended Posts

Very new to PHP.

 

Details:

I am using a form on my site using a PHP middleware page to send the data to an email address.

The validation sends the user to an "error.html" page or an ok.html" page if the forms are filled out properly or incorrectly. The form is inside an IFRAME (maybe not the best way to do it, but there you are) and when the page redirects the user after the form is filled out, the "ok.html" or "error.html" loads within that IFRAME instead of a new load.

 

The current script is (in part):

 

print "<meta http-equiv=\refresh\" content=\"0;URL=error.html">";

 

I was trying to something like:

 

print "<meta http-equiv=\refresh\" content=\"0;URL=error.html target="_parent">";

 

That doesn't seem to work and with my limited knowledge of PHP...it's a no go.

 

How would I add a "target" to this line properly?

 

Thanks!

 

Cheers! - J. Declan

The site reports an error suggesting that the page "error.html" does not exist, placing a % sign between the site address and the word "target"...

 

Could it be the [sPACE] between "error.html" and "target" may be causing the problem?

 

In short, your suggestion did not work. And to be honest, I dropped a quote sign from the string. The exact wording is: print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";.

 

I appreciate your help.

 

Cheers - J. Declan

Why don't you just use single quotes to delimit the string, then you don't have to worry about escaping the double quotes:

<?php
print '<meta http-equiv="refresh" content="0;URL=error.html">';
?>

 

Please post the exact error you're getting.

 

Ken

I am very new to PHP, so your question is a good one, but one I cannot answer...  ???

The error I am getting places this [%20] between the URL link and the target="_parent" that I am trying to use. There's a great possibility I am going about this incorrectly...no doubt.

 

Again, the line of code I have is:

print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";

And what I'd like to do is have it load the "error.html" page, which is now loading inside my <iframe> to load outside of it, as a refresh.

 

I am unsure how to do this without using a space which is the reason I am getting the [%20] error, or "Page not Found".

 

Thanks again! I appreciate the help.

 

-J Declan  8)

That's cool. I am still new to this.

 

My problem is the form I am using is inside an <iframe> and it uses this PHP page as middleware. The PHP sends the user to an "error.html" or "ok.html" page after the user hits the SEND button, but because this send button is technically inside an <iframe> it loads those pages inside the same <iframe>. I am trying to prevent that. I am trying to get it to load outside the <iframe>.

 

I have other pages inside <iframes> and when using the <a href> tag I simply add the "target="_parent" and it works great. But this PHP page won't allow me to add a "target"

to it, reporting a "Page Not Found" and using the "%20" error because I keep using the wrong syntax.

 

If anyone can tell me how to rewrite the line within my PHP page:

print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";

with better syntax so it will load outside my <iframe> - that would be sweet.  :o

 

Thanks!

 

J.Declan

Instead of redirecting them if there is an error. Why not just show an error message on the same page?

 

Also i don't think there is any way in PHP or HTML to redirect to another page (in a new tab/window) without the user clicking a link.

 

You could always try javascript

I get the sense there is no way to do this, too. I've been researching it all day.

 

I am all for an error message or a "thank you" message on the same page, or the same <iframe>...

Just don't know how to do it.  ???

 

Thanks.

Signed, Clueless Noob

Without looking at your code i would just say replace the

print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";

with

echo "There is an error";

 

If you want another way to do this i have just wrote this code for my snippet site

<?php
//Filename: contact.php
//Description: This is a simple contact form to allow people to contact you.
//Un-tested

function make_safe($un_safe)/*Nice little function i made to run the code through some safety measures*/
{
$safe = trim($un_safe);//Removes any whitespace
$safe = htmlentities($safe);/*makes any tags into safe versions (special char versions)*/
return $safe;
}

function check_len($check,$remove)/*used to check the length of a word (can also remove any spaces in the word)*/
{
if($remove == true)
{
	$check = str_replace(" ","",$check);
}
$check = make_safe($check);
$check = strlen($check);
return $check;
}


//To learn how to send a basic email from php refer to my previous mail tutorial
//http://djw-webdesign.awardspace.com/code.php?snippet=3
//Or the php manual http://uk3.php.net/manual/en/function.mail.php

if(isset($_POST['Send_me']))
{
//Save everything posted in a variable and make it safe 
$name = make_safe($_POST['Name']);
$email = make_safe($_POST['Email']);
$query = make_safe($_POST['Query']);
$message = make_safe($_POST['Message']);

//Check the length of all the compulsary inputs
if(check_len($name,true) == 0)
	$error[] = "Please enter your name";
if(check_len($query,true) == 0)
	$error[] = "Please select what the message is regarding";	
if(check_len($message,true) == 0)
	$error[] = "Please enter a message";

//Check for certains chars in an email address
if(check_len($email,true) > 0)
{
	$real = array("@",".");
	if(strpos($email,$real) == 0)
		$error[] = "Invalid email address";
}

//If there is no variable called $error
if(!isset($error))
{		
	//Sent From
	$sender = "Someone somwhere < someone@somesite.com >";

	//About
	$subject = "Site contact - ".$query;

	//Sent To yourself
	$recipient = "me< Me@hotmail.com >";

	$message = "
	<html>
	<body>
	You have recieved a message from ".$name." from the site.<br> They contacted you regarding ".$query.".<br> They left this email for you to reply to them on.<br><a href=\"mailto:".$email."\">".$email."</a>
	</body>
	</html>
	";//you will need to escape any double quotation marks.like shown above.

	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From:'. $sender . "\r\n";
	//for more information on headers refer to the php manual mail function.
	mail($recipient,$subject,$message,$headers);// PHP manual function reference - http://uk3.php.net/manual/en/function.mail.php
}
}
?>
<!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=utf-8">
<title>Mail Form</title>
</head>
<body>
<?php 
if(isset($error))
{
echo "There was an error proccessing the request, please correct the below errors<br>";
foreach($error as $er)
{
	echo "   ".$er."<br>";
}
echo "<br>";
}
?>
A star(*) indicates a compulsary input field.
<!-- This is a basic form that we will use for inputting the mail, there are html tutorials to explain how to use forms -->
<form action="" method="post">
*Name: <input type="text" name="Name" value="" maxlength="20"><br>
Email: <input type="text" name="Email" value="" maxlength="20"><br>
*Regarding: 
<select name="Query">
	<option selected="selected" disabled="disabled"></option>
	<option value="general">General</option>
	<option value="snippet error">Snippet Error</option>
	<option value="missing page">Missing Page</option>
</select>
<br>
*Message: <br>
<textarea rows="5" cols="30" name="Message"></textarea>
<br>
<br>
<input type="submit" name="Send_me" value="Send Mail">
</form>
</body>
</html>

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.