PDA

View Full Version : Send form to two places



allsims1
05-20-2007, 05:01 AM
Hi,

I'm a novice with PHP so can anyone help me?

I'm trying to send the same form to two different places on submitting. Does anyone have an idea on what I can do? Thanks!

Derek

djr33
05-20-2007, 06:38 AM
There is a way to do what you need, I'd think.

But we need to know a bit more.

Two places?

Emails? (Just use a comma between addresses)

PHP processing pages?
...that gets complex.
Options:
-open a second window, too, but that would be annoying as well as take some complex code, perhaps.
-use a php include to do the same function of the other page, if possible
-do one then the other, forwarding the posted data (could be hard, depending)

boogyman
05-20-2007, 04:00 PM
Emails? (Just use a comma between addresses)

that doesn't always work well. if you are trying to send to your email and the senders / some input the user defines, you can use the header() function to CC: it.



// Get's the Message Ready
$to = "your_email@url.com";
$subject = "subject_of_email";
$message = "";
$user_email = $_REQUEST['email'];

// Sends Mail
mail($to, $subject, $message, "CC: $user_email")


now if you have more then 2 places, you can create an array of email addresses, then loop through the array to send to each email address seperately.



$receipient[0] = "email1@address.com";
$receipient[1] = "email2@address.com";
$receipient[2] = "email3@address.com";
$receipient[3] = "email4@address.com";
$receipient[4] = "email5@address.com";

foreach($receipient as $add) {
mail($add; $subject, $message);
}
// Where subject and message are the same as format as defined in first example

djr33
05-20-2007, 09:25 PM
commas are supported by the offical format of emailing.

Proper:
1@1.1, 2@2.2, 3@3.3
<name1> 1@1.1, <name2> 2@2.2

etc

allsims1
05-21-2007, 02:25 AM
I'm sorry, I knew after thinking about my post this afternoon I wasn't too specific.

Basically, the form is filled out and the directs you to your webmail account, but I also want the form to send the form's details to your mail.

Basically I have the PHP that sends the mail but my objective is this:

Send the mail silently, while displaying the page that logs you into the mail.

It all uses the same form so I would think it would be easy, and if the mail can't be sent "silently" I wouldn't care if like for example a pop-up came up saying "A copy of this form was sent to $email" or something along those lines.

If you still are confused please let me know...

Also I was thinking of ideas last night... If you know how to embed forms and have it do both objectives (1. redirect to webmail & 2. send a copy of the form to the person logging in) that way might work...

Also you may ask, why does an email have to be sent, I'd like the email to be sent so that we can determine if people are trying to compromise someones account using the webmail login form.

Please let me know if you have any ideas, thanks a bunch!




Also another idea, which I'm assuming is hard... but have the page that says "an email was sent to your account bla bla bla.." instead start redirecting you to the webmail page after sending the message, and have the webmail page use the information the form just sent to redirect you correctly... Let me know, although I'd prefer to just send the email silently and have the webmail sign the person in... Thanks



Arg sorry to keep editing! I actually found my solution! :-D woot! Searched on google: two actions one form, found this: http://www.webdeveloper.com/forum/showthread.php?t=89922 works great, i don't have to edit my PHP (which I'm terrible at) and can just use trusty good ol' frames... Woot! Sorry for troubling you all and wasting your time.... Thanks however, I'm glad you guys were there to spark my mind!

boogyman
05-21-2007, 05:12 PM
Basically, the form is filled out and the directs you to your webmail account, but I also want the form to send the form's details to your mail.
what is the purpose of filling out an email form to then be directed to your mail account to have to fill it in again?


Send the mail silently, while displaying the page that logs you into the mail.

It all uses the same form so I would think it would be easy, and if the mail can't be sent "silently" I wouldn't care if like for example a pop-up came up saying "A copy of this form was sent to $email" or something along those lines.

"silently" is all dependent on how the developer decides it to be. using the php mail script by default will be "silent" meaning that it wont give you a success / fail message on the screen unless you tell it to. If it does fail then it will be sent back to the server, but the developer would need to have access to the error log file which isn't web-accessible by default.
In most cases though it is a good idea to let the user know if the email has been sent or not, as a way of saying this thing actually worked... it can be very frustrating to users if they take the time to fill something out and try to send it and do not get a confirmation of some sort.


Also I was thinking of ideas last night... If you know how to embed forms and have it do both objectives (1. redirect to webmail & 2. send a copy of the form to the person logging in) that way might work
Also you may ask, why does an email have to be sent, I'd like the email to be sent so that we can determine if people are trying to compromise someones account using the webmail login form.
so your form is something that is going to log into a mail client? I am then assuming that the reason you want to have the email sent silently is because you would like to "hijack" the person's password? and it wouldn't matter if someone was trying to compromise the account because you are going to just see what is being entered. Unless you use some $_SERVER variables in the email to determine some other aspects of the communication




Also another idea, which I'm assuming is hard... but have the page that says "an email was sent to your account bla bla bla.." instead start redirecting you to the webmail page after sending the message, and have the webmail page use the information the form just sent to redirect you correctly... Let me know, although I'd prefer to just send the email silently and have the webmail sign the person in... Thanks



<form method="post" action="WEBMAILACTION" onsubmit="process_to_email.php">
...
</form>


that will submit it to both the login of whatever mail client you are trying to get at, and it will send the details to some "process_to_email.php" that can be on your server.



use trusty good ol' frames... Woot!
Frames are not that great :(

djr33
05-21-2007, 07:19 PM
I agree about tracking the passwords. Not so nice, I'd say. But... depends. I'd suggest warning your users at least.

The main thing to realize here is that you don't need to send it two places but just alter the script to do two things. PHP isn't limited in how much it can do on a single page, so there's no reason you can't just do the first task, then the second, then be done, rather than routing through two pages.

allsims1
05-21-2007, 08:14 PM
Hijack the person's password? No, I'm not that good with PHP. But actually its a login form for my friends, its so we can login to gmail, our school blocks all https websites so gmail doesn't work, the technologist doesn't want to block gmail she told me, it's just that since everyone was bypassing the blocked websites by inserting the "s" after "http" so she had to block all https websites....

So anyway the login for logs you into a pop webmail server. And my friends and I said we wanted a copy of every login so we can see if some of the other students are trying to login to our accounts, since a lot of the kids are smart enough to probably "hijack" our passwords. We want it to be sent silently so then the hijacker doesn't know the login information is being sent to the account.

Also, I was being sarcastic when I said "good ol' frames" lol

Anyway, thanks a bunch for the help! However I'm flattered that you think I'm capable of "hijacking" accounts lol I wish I was that good with PHP. All I know is html and barely any php, well cya, thanks

boogyman
05-21-2007, 08:39 PM
Hijack the person's password? No, I'm not that good with PHP. But actually its a login form for my friends, its so we can login to gmail, our school blocks all https websites so gmail doesn't work, the technologist doesn't want to block gmail she told me, it's just that since everyone was bypassing the blocked websites by inserting the "s" after "http" so she had to block all https websites....
there usually is a reason why system administrators block websites at schools.



So anyway the login for logs you into a pop webmail server. And my friends and I said we wanted a copy of every login so we can see if some of the other students are trying to login to our accounts, since a lot of the kids are smart enough to probably "hijack" our passwords. We want it to be sent silently so then the hijacker doesn't know the login information is being sent to the account.
...
I'm flattered that you think I'm capable of "hijacking" accounts lol I wish I was that good with PHP. All I know is html and barely any php, well cya, thanks
but why would you send EVERY login to your email? that really just doesn't sound right. and if you know the mail() function in php then you can use it to send the information... heck I told you how in my reply how to use the mail function. Trying to bypass your school system is one thing, but tracking logins is something else entirely, and if caught you could be given some heavy punishment because you are not an administrator, and you are looking at passwords, so it could be perceive as malicious behavior, even if yo don't do anything, the perception of intent is there.

djr33
05-21-2007, 10:34 PM
That IS tracking passwords.

A password is just sent to the next page. If you save that, then that's all you'd need to do. It's not hard. As such, you don't need any great skills if you have access to the page. I'd never trust a homemade rerouting thing to gmail.

On top of that, how does it work? https will still be used for gmail even if logged in. Perhaps you mean you're using a 3rd party pop3 email server?

I suppose it could work.

I'd also not want to give my teacher my password, so even if for 'good', I wouldn't trust that system, where she gets all the logins. That's a big invasion of privacy.

allsims1
05-22-2007, 01:29 AM
I just re-route it to http://www.email4web.com

Also I think you're missing the point, the email that is entered into the login page is send the copy of the form, not anyone else. It lets us track if anyone but us is logging in.

Also it actually did work, we tried it today, a few of us didn't have POP forwarding enabled, but mine already did since I used Outlook so I already had it turned on so it worked! It's pretty awesome and I'm really happy I can see if someone's trying to login to my account.

Also even if you do think I'm "hijacking" someones password, well I have nothing to prove to you, I know I'm not and also know I'm not even smart enough with PHP to do it.

Thanks though!

djr33
05-22-2007, 01:50 AM
Oh, ok.

You are logging passwords, but if you're just sending to the user logging in, then that seems fair enough, though perhaps tiresome considering that you'd get an email every time.
(I think we were both under the impression that you are sending the logs to the administrator of your class/school, not the individual users.)

The thing is.... who cares if someone is guessing your password? If they log in correctly you won't notice the logged email with the correct password just like yours, or they could even just delete it themselves.

Anyway, that seems like it would work. ...maybe.

The problem here is that you may actually need to send the data twice, since you're using two different pages, your own, and the real login script (http://www.email4web.com/dologin.php).
You can't just forward post data and using get instead would be insecure as well as likely not working too well.

Sending post data again is tough and limited to, I think, just ajax, java applets, flash, and other complex things you probably don't want to go into.

My idea, then, would be to create a mirror of the form, using hidden fields of the same names, populated using the values sent to your page. Then use a "continue to login" button as submit and they will then send the data twice.

That's really the only option I can think of without a lot of reworking.

You could do a lot more if you could recode the login page, but that's not yours to change, so you won't have any luck there.

boogyman
05-22-2007, 12:50 PM
(I think we were both under the impression that you are sending the logs to the administrator of your class/school, not the individual users.)
thats the impression i got :|

Also even if you do think I'm "hijacking" someones password, well I have nothing to prove to you, I know I'm not and also know I'm not even smart enough with PHP to do it.yes you are smart enough. if like i explained to you, you use the mail() function that I posted in one of my earlier replies you can send it to whomever you want... thus hijack. you dont have to physically take over the computer, but now we know thats not what you were attempting to communicate.