php include question.
Moderator: General Moderators
php include question.
Hi, anyone know if you can send a form action to a php include or php function instead of php elsewhere? So that it will execute code when submit is clicked? I am trying to get echo's to appear on the web page when a form is sent with php instead of black text on the blank page in server land. If anyone knows of a way to get an echo on the web page itself please let me know, thank you very much.
I just want when a submit button is clicked on for the echo message to appear on the web page it is on. Instead of the blank white page that echo's normally appear on.
Thats it.
The submit sends to php on the same page or to php on another page elsewhere.
The php sends all the form fields to an email address. Thanks.
Thats it.
The submit sends to php on the same page or to php on another page elsewhere.
The php sends all the form fields to an email address. Thanks.
- snowrhythm
- Forum Commoner
- Posts: 75
- Joined: Thu May 04, 2006 1:14 pm
- Location: North Bay Area, CA
- jyhm
- Forum Contributor
- Posts: 228
- Joined: Tue Dec 19, 2006 10:08 pm
- Location: Connecticut, USA
- Contact:
Just to chime in on what snowrhythm said,
I think what you want to do is make sure the form action is set to the same page that the form is on.
I think what you want to do is make sure the form action is set to the same page that the form is on.
Code: Select all
<form action="form_page.php">- snowrhythm
- Forum Commoner
- Posts: 75
- Joined: Thu May 04, 2006 1:14 pm
- Location: North Bay Area, CA
LOL, you guys are busting me up. I love your humor. I like your new approach, hope it works. I'm getting an error on the session action="$_SESSION['php_self']" Am I supposed to put the page address in the php _self spot?
Using the same address seems to be doing something. But its not sending to the email when the submit is pushed. I think its because it needs to look for the specific email code only on the page when the submit is pushed. As it is now, its looking at the code on the whole page.
Anyway to have it look at the email code only on the page without trying to launch the rest?
Or maybe you have ideas with this to get an echo to appear on the same page. When the submit button is pushed the echo appears on the same page. What do you think? I tried this though, nothing happened. I think I have the if post written incorrectly. Anyone know the right way?
if (isset($_POST[submit])
{
echo "submission successful";
}
Using the same address seems to be doing something. But its not sending to the email when the submit is pushed. I think its because it needs to look for the specific email code only on the page when the submit is pushed. As it is now, its looking at the code on the whole page.
Anyway to have it look at the email code only on the page without trying to launch the rest?
Or maybe you have ideas with this to get an echo to appear on the same page. When the submit button is pushed the echo appears on the same page. What do you think? I tried this though, nothing happened. I think I have the if post written incorrectly. Anyone know the right way?
if (isset($_POST[submit])
{
echo "submission successful";
}
you're not supposed to put the actual url instead of 'php_self'. can you post your whole form? you're probably missing something like...
try this in your form tag...
you may get away with
see if that works.
Code: Select all
$input_field1 = $_POST['input_field1'];
$input_field2 = $_POST['input_field2'];Code: Select all
<form action="<? echo $_SERVER['php_self']; ?>" method="post">Code: Select all
<form action="<? $_SERVER['php_self']; ?>" method="post">
Last edited by boo_lolly on Wed Jan 03, 2007 5:56 pm, edited 2 times in total.
- jyhm
- Forum Contributor
- Posts: 228
- Joined: Tue Dec 19, 2006 10:08 pm
- Location: Connecticut, USA
- Contact:
You'll have to be more specific,
try posting all your code so we can see what is wrong.
Be careful when posting code on the boards.
viewtopic.php?t=8815
Line 9
try posting all your code so we can see what is wrong.
Be careful when posting code on the boards.
viewtopic.php?t=8815
Line 9
Are you guys refering to
?
$_SESSION['php_self'] shouldn't exist unless you have it set.
Also, a more safer way to post a form to the same page is use #
Code: Select all
$_SERVER['php_self']$_SESSION['php_self'] shouldn't exist unless you have it set.
Also, a more safer way to post a form to the same page is use #
Code: Select all
<form method="post" name="some_form" action="#">
...
</form>as far as i know, $_SERVER['php_self'] is a global variable, it will never change, meaning you can use it anywhere on any page and it will always call itself. using '#' as the form action will only bump you up to the top page. i don't think it will do anything else. possibly, it won't even post the input fields.mickd wrote:Are you guys refering to
?Code: Select all
$_SERVER['php_self']
$_SESSION['php_self'] shouldn't exist unless you have it set.
Also, a more safer way to post a form to the same page is use #
Code: Select all
<form method="post" name="some_form" action="#"> ... </form>
- snowrhythm
- Forum Commoner
- Posts: 75
- Joined: Thu May 04, 2006 1:14 pm
- Location: North Bay Area, CA
OK here ya go, but do I even need all this, if an echo can appear when the button is pushed?
I'm game to try it.
Whoaaa, thats a lot of color.
I'm game to try it.
Code: Select all
<?php
while ($row = mysql_fetch_array($result))
//other stuff up here that works fine. That pops up this form.
{
//this following form works fine too and sends to an email, when the email php is listed on a separate page. ( I include that under this so you can see it.) But when I try to include the email form within like this, it won't send to the email when the submit button is pushed.
$mailto = 'emailaddress@whatever.com';
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>
<input type='text' name='sendingfield' size=15>
<input type='submit' name='submit' value='submit' /></form>;
$another = $_POST['sendingfield']; //field that sends to email when submit is pushed'
$subject = 'Subject' for email;
$uself = 0;
$sep = (!isset( $uself ) ¦¦ ($uself == 0))? '\r\n' : '\n' ; //puts fields into email correctly.
$messageproper = 'Filled field listed in email field: $another\n';
mail($mailto, $subject, $messageproper, 'From:' . $sep . 'Reply-To:' . $sep); ";}}
//maybe I need an "if" echo down here if the submit button is pushed.
?>
_______________________________________________________________________
//And you probably don't need this, but if you want to look at it.
Here's how it looks when sending the field to the email form on a separate page.
echo "<form action='sendemail.php' method='post'>
<input type='text' name='sendingfield' size=15>
<input type='submit' name='submit' value='submit' /></form>";
And the sendemail.php on separate page that sends field to email.
$mailto = 'emailaddress@whatever.com';
$another = $_POST['sendingfield']; //field that sends to email when submit is pushed'
$subject = 'Subject' for email;
$uself = 0;
$sep = (!isset( $uself ) ¦¦ ($uself == 0))? '\r\n' : '\n' ; //puts fields into email correctly.
$messageproper = 'Filled field listed in email field: $another\n';
mail($mailto, $subject, $messageproper, 'From:' . $sep . 'Reply-To:' . $sep); ";}}
?>