473,794 Members | 2,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using same script in email handling and POST web form

Hi All, I have a script sitting on my web server called
auto_mail.php5. I would like this to be used two different ways.

One way would be for a web form to call it as submit action on a form.
I have got this working great.

However, to get this to work I had to comment out the first line of
the script which is #!/usr/bin/php -q

Now the other way the script is called doesn't work any more! This
other way is that when xx**@beckhallma lham.com receives an email it
forwards the email to |/home/beckhall/public_html/php/auto_mail.php5

Since I removed that first line the forwarder never invokes the
script! If I put the first line back in then the forwarder works but
the web post does not. This is because the web post later does a
HEADER("newurl" ) to do a redirect, and this fails as text has already
been posted to the form. catch-22!

Any suggestions? I would guess but I'm no expert that the best
solution would be to tell the email forwarded to use php to process
the auto_mail.php5, but I don't know how to do this! Maybe the
forwarder to go to another script, that then calls auto_mail.php5?

Cheers for any help,

Simon
Jul 22 '08 #1
5 1534
On Jul 22, 3:35 pm, simon m <SIMON.MA...@us a.netwrote:
Hi All, I have a script sitting on my web server called
auto_mail.php5. I would like this to be used two different ways.

One way would be for a web form to call it as submit action on a form.
I have got this working great.

However, to get this to work I had to comment out the first line of
the script which is #!/usr/bin/php -q

Now the other way the script is called doesn't work any more! This
other way is that when x...@beckhallma lham.com receives an email it
forwards the email to |/home/beckhall/public_html/php/auto_mail.php5

Since I removed that first line the forwarder never invokes the
script! If I put the first line back in then the forwarder works but
the web post does not. This is because the web post later does a
HEADER("newurl" ) to do a redirect, and this fails as text has already
been posted to the form. catch-22!

Any suggestions? I would guess but I'm no expert that the best
solution would be to tell the email forwarded to use php to process
the auto_mail.php5, but I don't know how to do this! Maybe the
forwarder to go to another script, that then calls auto_mail.php5?

Cheers for any help,

Simon
forward the email to |/usr/bin/php -q /home/beckhall/public_html/php/
auto_mail.php5

(check the path of PHP - it may not be /usr/bin/php)

C.
Jul 23 '08 #2
>
forward the email to |/usr/bin/php -q /home/beckhall/public_html/php/
auto_mail.php5
Hi All, I just tried the above but the control panel which I think is
cpanel X on Apache 1.3.37 (Unix) on a shared server parses out the /
usr/bin/php -q bit when I paste it into the "forward to" box. There is
also some help text that says no need to put the php or cgi bits in,
but be sure to place the appropriate shebang at the top of the script.
Argh!

How about a php script that the email forwards to withe shebang, that
can calls auto_mail.php5? Is there a way to do this, like #include
another php script in another one?

Simon

Jul 24 '08 #3
simon m escribió:
>forward the email to |/usr/bin/php -q /home/beckhall/public_html/php/
auto_mail.ph p5

Hi All, I just tried the above but the control panel which I think is
cpanel X on Apache 1.3.37 (Unix) on a shared server parses out the /
usr/bin/php -q bit when I paste it into the "forward to" box.
Then you'll need to write a small shell script to launch it, let's say
"auto_mail. sh":

#!/bin/bash
/usr/bin/php -q /home/beckhall/public_html/php/auto_mail.php5

And you would forward e-mail to |/path/to/auto_mail.sh

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jul 24 '08 #4
Álvaro G. Vicario escribió:
Then you'll need to write a small shell script to launch it, let's say
"auto_mail. sh":

#!/bin/bash
/usr/bin/php -q /home/beckhall/public_html/php/auto_mail.php5

And you would forward e-mail to |/path/to/auto_mail.sh
Hmmm... Now I think about it, I'm not sure my sample script is quite
right... Maybe you need to pass the standard input to the *.php file :-?

I'm sorry, I should not be writing bash scripts when I don't have any
Unix box where to test them.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jul 24 '08 #5
sorted! I have the original script auto_mail.php5, without the shebang
and the webpage calls this. All works OK.

the email now goes to iknow_wrapper.p hp and this has the shebang in
it, then an include("auto_m ail.php5") in it and that's all.

yeah! Thanks for all the pointers. I use www.php.net as a mega
resource, but like a lot of documentation it only really helps when
you know how to do something and need to clear up the details!

Simon
Jul 24 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2900
by: Mats Olsson | last post by:
I have an xml file, which is to be updated by an asp script (vbs) when users are submitting forms from their browsers. Now I wonder if there is anything that stops the following to occur: 1. User A submits form, resulting in asp script to create MSXML2.DOMDocument.4.0, which loads the xml file and updates the in-memory DOM tree 2. User B submits form, roughly at the same time, also resulting in asp script to create...
4
2234
by: Scott Baxter | last post by:
Hello, I got the following scripts to upload files to my directories I call insert.htm Browse for a file, then click 'submit' It works for small files, and for a small .mdb (access file)
19
4110
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
4
3175
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. Tables: (abbreviated) TblDivision DivisionID
15
4780
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
1
2391
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I look for when evaluating someone's code is a try/catch block. While it isn't a perfect indicator, exception handling is one of the few things that quickly speak about the quality of code. Within seconds you might discover that the code author...
6
32820
by: Boldgeek | last post by:
I am trying to develop an app that will allow automatic updating of a web form which uses multipart/form-data enctype (as it MIGHT be sending an image) I have an example form, which when submitted displays the results as you would expect. However when I send the same data using the PHP script I get a 400 error: Bad Request
10
2443
by: eggie5 | last post by:
Is it possible to get a file without using a form post? I want to get the data (bytes) of a file, text or binary, and just save it to a variable. Similar to the post body of a form that has a file input element in it. Ultimately what I want to do is get a file off client machine (that they specify) and send it to the server using a standard post request. This is exactly the same as a form post with an file input element, but I don't...
21
34440
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.