Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to hide email script 3

Status
Not open for further replies.

deecee

Technical User
Aug 25, 2001
1,678
US

you can enter your email and then the form is processed through
but you can go straight to
how can i make it so that you can only go to the email page if you enter your email because I still get emails if i just type
Is it even possible to deny access to the page unless there is a variable passed on [soapbox]
sleep is good
 
Make sure that the element "emailbox" is present in $_POST.

If a user goes to test.php, enters and address, and submits, the form field will be submitted to email.php.

However, if a user just goes to email.php (by typing it in the URL, injudicious use of the back and forward buttons, etc), then since no data will have been submitted, $_POST will not have been populated with the data from the form field "emailbox". Want the best answers? Ask the best questions: TANSTAAFL!
 
ok a little bit clearer but how would this look in a script wise

Would i use $_post in email.php or in test.php [soapbox]
sleep is good
 
The test would be performed in email.php.

Use array_key_exists() ( to see whether the key "emailbox" exists in $_POST.

This means that no form data was ever posted -- a sure sign that the user did not get to email.php by way of test.php. Want the best answers? Ask the best questions: TANSTAAFL!
 
ok i think im getting there, this is my first week in php so bear with me, do i still need <?php track_vars?> to start off my script in email.php?

also how would i code the $_post line

as of right now here is my simple mail code

<?php //PHP ADODB document - made with PHAkt 2.2.0?>
<html>
<head>
<link href=&quot;main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
</head>
<body>
<?php_track_vars?>
<?php

$msg = &quot;Sender's Email:\t$emailbox\n\n&quot;;

$mailheaders = &quot;From: Lilliek.com\n&quot;;
$mailheaders .= &quot;Reply-to: $emailbox\n\n&quot;;

mail(&quot;DarrynC@hotmail.com&quot;, &quot;Email Address&quot;, $msg, $mailheaders);

echo &quot;<h3 align=center>Thank You</H3>&quot;;
echo &quot;<p align=center class='email'>$emailbox Has Been Added To Our Mailing List.<br>We Do Not Share Our Mailing List With Anyone</p>&quot;;
echo &quot;<p align=center class='email'><a href=' to LillieK.Com</a></p>&quot;;

?>
</body>
</html> [soapbox]
sleep is good
 
also why is there a . after the second mailheaders? [soapbox]
sleep is good
 
also how would i use $_post in my script...does it go in the top or bottom or how would i work it out (even if there were multiple variables)

this is all so fascinating, wish i didnt get my degreen in economics and political scinece now :( [soapbox]
sleep is good
 
$_POST, $_GET, etc (or their older cognates $HTTP_POST_VARS, $HTTP_GET_VARS, etc) are arrays. If you have a POST-method HTML form which submits to a script, PHP will populate the array $_POST with entries in the form of $_POST[<html field name>] = <html field value>.

The one gotcha that bit someone in the forum this week -- the new superglobals are only available in PHP version 4.1.0 or newer.

They explain it better in the online manual that I ever could. Read here: Want the best answers? Ask the best questions: TANSTAAFL!
 
thanks a heap mon! time to upgrade my php3 manual ..... [soapbox]
sleep is good
 
ok i tried defining my variables like so

$email = $_POST['$email'];

it didnt do anything

so i have this script now

<?php //PHP ADODB document - made with PHAkt 2.2.0?>
<html>
<head>
<link href=&quot;main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
<meta content=&quot;text/html; charset=iso-8859-1&quot; http-equiv=&quot;Content-Type&quot;><title>EMAIL</title></head>
<body>
<?php
if (!isset($firstName) || !isset($lastName) || !isset($email) || !isset($accountNumber) || !isset($question)) {
header (&quot;Location: }
elseif (empty($firstName) || empty($lastName) || empty($email) || empty($accountNumber) || empty($question)) {
header (&quot;Location: }
else {
mail (&quot;darryn@cascadecorp.com&quot;, &quot;Feedback Form Results&quot;,
$firstName/n, $lastName/n, $accountNumber/n, $question/n, &quot;From: $email&quot;);
header (&quot;Location: }
?>
</body>
</html>

and this doesnt even work....what am i doing wrong, all i want to do is validate that the required fields are filled and that the email.php script cannot be accessed unless processed through contact.php (the form page) [soapbox]
sleep is good
 
ok i tried this to test it out but it dint work

<html>
<head>
<link href=&quot;main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
<meta content=&quot;text/html; charset=iso-8859-1&quot; http-equiv=&quot;Content-Type&quot;><title>EMAIL</title></head>
<body>
<?php
if (array_key_exists('firstName', $_POST))
{ header(&quot;Location: }

else { header(&quot;location: }
?>
</body>
</html>

Is there a good book for beginners that you could point me to. Cuz I even copy and paste code and it still wont work. [soapbox]
sleep is good
 
ok when i first go to the form and submit it it doesnt submit, but it goes to email.php, also i submit with all fields blank and it goes to email.php, then i enter the url into the adress bar and I go to email.php and thats it. The form doesnt get processed, as well as the page is available when nothing is entered in the form or when you browse directly.

I really appreciate your help [soapbox]
sleep is good
 
Here's what works on my machine:

I have a file test_noinput.html, which consists of:

Code:
<html><body>
<form method=post action=test_noinput.php>
	<input type=text name=foo>
	<input type=submit>
</form>
</body></html>

test_noinput.php consists of:

Code:
<?php
if (array_key_exists('foo', $_POST))
{
	print '<pre>';
	print_r ($_POST);
}
else
{
	print 'no input';
}
?>

If I pull up test_input.html in my browser, enter the value &quot;a&quot; in the text box, and submit, I get:

Code:
Array
(
    [foo] => a
)

If I pull up test_input.html in my browser, leave the field blank and submit, I get:

Code:
Array
(
    [foo] => 
)[/code[

if I just point my browser to test_noinput.php, then I get:

[code]no input

My recommendation will check whether HTML form fields exist as input, not whether the data in the fields is well-formed -- checking for well-formedness of input was not a part of your question. Want the best answers? Ask the best questions: TANSTAAFL!
 
So, you're clicking submit, and you're browser address bar changes to email.php, but then it hangs?

If that's what you're saying, it's likely a few problematic lines which are confusing the parser to the point it won't continue.

If it's actually completing a blank page then that's almost certainlly the problem... as sleipnir continually asks people, is your error checking turned on?

I would suggest this for debugging for starters... create a new email.php and only put these lines in it.

<?php
echo &quot;<pre>\n&quot;;
print_r($_POST);
print_r($_GET);
?>

And then you'll know if you're at least passing the data to email.php... if you are, systematically add your code back in a few lines at a time to figure out where it's broken.

Just some debugging tips, sorry if I've gone too far backwards.

-Rob
 
O....well I have 2 issues I am trying to resolve, first is I dont want my processing script (email.php) to be accesed unless you hit the submit button on the form, so if you want to browse directly to email.php it will not be possible. Second I want to check that 6 of the fields in my form has a value before the form will be processed.

[soapbox]
sleep is good
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top