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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email form again 2

Status
Not open for further replies.

d0s

Programmer
Apr 15, 2004
48
US
ok, i just got tired of trying to do things the way i was doing it and just started over. now i have the form and the php mail function and everything all in the same php file. Im having some problems tho when trying to submit the form. I did some searching online and i saw someone talking about using $php_self for calling on the same application or whatever so i use it in my form tag like so:
Code:
<form action="<?= $PHP_SELF ?>" method="post">
When i try it like this, this gets displayed: Sorry, such file doesn't exist...

ok so i try setting the path to it and using the php_self like so
Code:
<form action="modules/testapp/<?= $PHP_SELF ?>" method="post">
i get a page cannot be displayed. When i look at the address bar it looks like this: modules/testapp//modules.php

so its looking for a modules.php when its suppose to be looking for an index.php. so then i decided to try using index.php like this
Code:
<form action="modules/testapp/index.php" method="post">
i get page cannot be displayed also, but that should work cause the path is even correct. in the address bar i see: modules/testapp/index.php
that should be right. anyone have any ideas. i could sure use some right now. Thanks
 
sorry forgot to add.. This server is being ran with FreeBSD Operating system, Apache version 1.3.29, PHP version 4.3.3 just incase you guys need that info..thanks
 
Try this instead:
<form name="email" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
 
hmmm nope..same thing file doesn't exist, but i did just notice something when using the $php_self by itself its looking for the file modules.php like this

URL/modules.php

but when i click on the link to go to the application its
URL/modules.php?name=TestApp

here my complete code incase you see something i don't
Code:
<html>
<head><title>Test Application</title>
</head>
<body>
<br>
<br>
<br>
<Center>
Test Application
</Center>
<br>
<br>
<br>
<br>
<br>

<?
if ($_POST) {
$name = $_POST['name'];
$email = $_POST['email'];
$text .= "$name has requested to join";
$text .= "****************************************************";
$text .= "Name: $name";
$text .= "Email: $email";
$text .= "****************************************************";
$text = $_POST['text'];
$subject = "Test App";
mail('myemail@location.com,$subject,$text,"From: $name <$email>");

}
else {

?>


<center>
<form name="bah" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

Name: <input type="text" name="name" size="30" maxlength="30"><br>
Email: <input type="text" name="email" size="30" maxlength="30"> <br>
Text: <TEXTAREA name="text" cols="50" rows="10"></text>
<br>
<br>
<input type="submit" name="submit" value="Send">
</font>
</form>
</center>
<?
}
?>
</body>
</html>
and i left the form action the same way you suggested last
 
hmm for my money i would just use the following:
Code:
<form name="bah" action="pagename.php" method="post">

where pagename is the name of the page this is in......

not very dynamic i know but it is only one little but.
 
i did that but it takes me to the main page...for some reason its trying to look for it in the main directory and not the modules/Testapp directory
 
When you display the program with your browser, do a "show source" to see that HTML is generated. Make sure that the target of the <form> is correct there.

You can also put a
Code:
phpinfo();
statement at the start of your code to see all the variables known when your program starts.

Ken
 
just one other thing.
Code:
if (isset($_POST['name']) and isset($_POST['email']))

and not
Code:
if ($_POST)

just a thought.
 
good call kenrbnsn..when i do that it shows
Code:
<form name="bah" action="/modules.php" method="post">
why is it doing that?
 
omg..sorry guys...i just figured out what the problem was...when setting the modules/testapp path i forgot this is on a FreeBSD system and that its case sensitive..it was really TestApp...lol man i feel stupid..thanks again guys. i got some good code out of this
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top