Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,474 members, 7,816,118 topics. Date: Friday, 03 May 2024 at 05:32 AM

Simple Php Error ! - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Simple Php Error ! (984 Views)

How To Create A Simple PHP Website With PBNL Anybody Can Do It! (naijazoom.com) / What Is Wrong With This Simple PHP - MYSQL Script / Another Simple Php/python/asp/etc Challenge (2) (3) (4)

(1) (Reply) (Go Down)

Simple Php Error ! by smartsoft(m): 12:57pm On Nov 05, 2008
hello guys just kind of sick here with this code, i'm creating a website for a Tv reality show that is aired on TV,  and they want to start using it voting stuff online too. apart from the short code service i don't do php again ooo but i could remember some simple codes like that,  this one is really giving me a challenge,  when u vote, it shows u a blank page instead of taken u too a thank you page,

don't know what is wrong can u guys check for me though it dumbs the info to the person email, but it doesn't take you to the thankyou page.

<?php
if(isset($_POST['submit'])) {
$headers="";
$headers4="whateva@yahoo.com";
$headers.="Reply-to: $headers4\n";
$headers .= "From: $headers4\n";
$to = "whateva@yahoo.com";
$subject = "Someone just voted an housemate";
$name = $_POST['name'];
$housemate = $_POST['housemate'];
$body = "From: $name\n Housemate Name:\n $housemate";
header("location: thankyou.html"wink;
mail($to, $subject, $body);
?>
Re: Simple Php Error ! by yawatide(f): 4:01pm On Nov 05, 2008
smart,

where else would a tv reality show be shown? newspaper? tongue

Anyways, what is in the "action" attribute of your form tag? This might be the answer to your problem. Also, hv u considered using a third party voting coding, code that you could easily configure to meet your needs? I am sure there plenty of free ones out there.

No need reinventing the wheel if you dont hv to wink
Re: Simple Php Error ! by kehers(m): 4:48pm On Nov 05, 2008
Hmmm, should mail() come after ur redirect? Snc u said d mail works then d redirect doesnt. Put d mail fnc before d header. Also try this after d header:

exit;
Hope that works.
Re: Simple Php Error ! by smartsoft(m): 6:41pm On Nov 05, 2008
of course now it is already on. soon they will start evicting and voting as well but already, they are using the short code thing. the project came to me very very late example : they wanted to do somthing tomorrow and they are given me 1hour after they have started,

Well for the voting bro,  not really a thing i should start crying abou  i just wanted viewer to just add their name and the housemate name and click vote and also 2 have a validation thing not that serious job
Re: Simple Php Error ! by TechPros(m): 7:08pm On Nov 05, 2008
@ yawatide
shocked  shocked i wasn't expecting that from u and still can't believe why u gave a wrong solution to a simple problem like this.

@ kehers

wink quite simple, isn't it ?

@ smartsoft

i know u, u are a professional. please set little time for web programming too. u need it
Re: Simple Php Error ! by yawatide(f): 7:12pm On Nov 05, 2008
tech pros, what exactly is wrong with what I have said?  That he should go hunt for 3rd party solution? or that he should do a spot check of his form tag?  And who are you to say the solution to something is simple? Simple by whose standards? Yours?

Did I ever tell you I know it all? Do you know it all? Okay, since you do, without copying, pasting and running in your browser, tell me what the answer to 6/0 in javascript is.

I dey wait.

Hmmm
Re: Simple Php Error ! by Nobody: 11:52pm On Nov 07, 2008
smartsoft:


<?php
if(isset($_POST['submit'])) {
$headers="";
$headers4="whateva@yahoo.com";
$headers.="Reply-to: $headers4\n";
$headers .= "From: $headers4\n";
$to = "whateva@yahoo.com";
$subject = "Someone just voted an housemate";
$name = $_POST['name'];
$housemate = $_POST['housemate'];
$body = "From: $name\n Housemate Name:\n $housemate";
header("location: thankyou.html"wink;
mail($to, $subject, $body);
?>

everything is wrong with your code

1. you defined header that you did not use
mail($to, $subject, $body, $headers);

2. like kehers said, mail() should come before header()

3. use CRLF(carriage return line feed) for mail headers instead of just the LF, so it should be \r\n

4. you did not close that curly brace, i am sure you did in your script }else{ it will not work

if you use the header function without ending it with exit;
the code after will be executed so take note


@yawa, my love, you disappoint me gan. nothing for you 2nyt
Re: Simple Php Error ! by yawatide(f): 12:34am On Nov 08, 2008
'xplain urself webdezzi
Re: Simple Php Error ! by pie1ect(m): 3:26pm On Nov 08, 2008
@ Smartsoft

This "header" redirection code does not work when placed inside <HTML> tags. Your code seems like it'll get the job done. I came across something of this nature when working on a church website with a few guys recently.

Check your code to make sure no text is sent to your browser . You could implement the mail and redirection separately but check first to see if they are working against each other. Also for good measure, close your curly bracket.

@Techpros and Webdezzi

Lay off Yawa. Any person who's been in web design for more than 6 months knows how time-saving third-party codes can be. Instead of trying to grand-stand, you might want to offer practical solutions.
Re: Simple Php Error ! by kehers(m): 3:58pm On Nov 08, 2008
pie1ect:
Lay off Yawa,
Hmm, toasting with style grin
Re: Simple Php Error ! by OmniPotens(m): 4:03pm On Nov 08, 2008
@pie
I just didn't want to say anything about their trying to crucify someone for making mention of third party codes. One question I think I will ask them is "have they ever tried copying, pasting and editing at least a JavaScript code they used on their web before?" Those that uploaded them there know how time consuming it is to always recode what has been coded before. It is useless wanting to waste more time on inventing what has been rather than editing and adding more features. Well, Naija man likes suffering that is one good feature I noticed  tongue

@smartsoft
If the coding doesn't get better and you can't finish in good time, get a third party code and edit. Those that don't like it should send you the codes else,  lipsrsealed
Re: Simple Php Error ! by yawatide(f): 6:05pm On Nov 08, 2008
kehers and omni,

No mind them o. They are still in the chest-thumping, "do you know who I am? I coded a facebook-type app all by myself in 24 hours" phase of their lives, a phase where they *think* they know it all.

I have been around for a while and the older I get, the more I have concluded that there is no need stressing one's self if someone else has already written something, especially if it is free (not copyright). Whether you do it yourself or get a plugin from somewhere, you are being paid the same amount of money.

At the end of the day, you spend 3 days coming up with something from scratch and I do the same thing in 3 hours - Who's the fool?
Re: Simple Php Error ! by smartsoft(m): 6:24pm On Nov 08, 2008
good good good, then i will look for a third party code and improvise, thanks
Re: Simple Php Error ! by OmniPotens(m): 10:19pm On Nov 08, 2008
@smartsoft
if that is your last option go ahead. Who will come and collect your money for plugging in a code from somewhere?

(1) (Reply)

Designing With Microsoft Frontpage / Website Designer Needed Asap / How Good Does Your Website Look In All Browsers?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 25
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.