Closed Thread Icon

Topic awaiting preservation: Form not sending mail using includes... PHP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21565" title="Pages that link to Topic awaiting preservation: Form not sending mail using includes...  PHP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Form not sending mail using includes...  PHP <span class="small">(Page 1 of 1)</span>\

 
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 04-27-2004 19:07

I have a form that will send an email to me as well as an auto-responder. Typical stuff for right now.

If I test the form using the full path : http://www.mojotone.com/pages/emailPage.php
then everything works fine. But, if I just use an include it doesn't. Like http://www.mojotone.com/index.php?link=email

Here is the php code in text format

I have a feeling it something really stupid.

Thanks in advance.

Later,

C:\


~Binary is best~

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 04-27-2004 19:24

if($_POST['Submit']) should probably be if (isset($_POST['Submit'])) - and I'd hope that Submit is not the submit button - for it would not be submitted the form's being sent with 'enter'.

Same goes for if ($_POST['phone'] != NULL) - that should be if (!isset($_POST['phone']) - if you'd add error_reporting(E_ALL), you'd get all kind of 'key not found' warnings.


Apart from that, you'll need to actually debug it - just add print("shu"); at places, to see if it actually goes into the right ifs. checking the result of mail() is also a nice idea - it could be reporting a failure, and you'd never know.

So long,

->Tyberius Prime

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 04-27-2004 21:44

Nope, still not working.

If I turn on error reporting I get "Undefined index:" but that is it.

The script still works from the /pages/emailPage.php but not when i use the index.php?link=email.

Any ideas?

Later,

C:\


~Binary is best~

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 04-27-2004 21:49

I would think you could not call the page from the url index.php?link=email and also expect to be able to send a "POST" to the same address. By issuing a call to index.php?link=email you are issuing a "GET" call. You can not issue both a get and a post at the same time.

<edit> The solution might have been needed. If you want to use the new address you will need to change your PHP variable handling to $_GET and your form's send method to "GET" that way all the information will be appended to the query string. </edit>



(Edited by WarMage on 04-27-2004 12:55)

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 04-27-2004 22:05

well.....how 'bout I just make it it's own separte page and just do it that way.

Using $_GET doesn't seem to work either while using index.php?link=email

Later,

C:\


~Binary is best~

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 04-27-2004 23:10

Your action is off. Presumably none of the email code is included if you don't have link=email in the url. (or wherever $_GET['link'] is parsed).

you haven't posted the code that wraps this page but either making the action

action="<? echo $_SERVER['PHP_SELF'.'?link=email' ...


or putting a hidden field in the form specifying link:

<input type="hidden" name="link" value="email">



Should do the trick.



.:[ Never resist a perfect moment ]:.

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 04-27-2004 23:54
quote:
action="<? echo $_SERVER['PHP_SELF'.'?link=email' ...



This right here did it! Thank you so much Bit! I was about to freak out.

Later,

C:\


~Binary is best~

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 04-28-2004 01:10

That is because PHP_SELF doesn't include the query string, and you need to append it.

« BackwardsOnwards »

Show Forum Drop Down Menu