/    Sign up×
Community /Pin to ProfileBookmark

Reading email from stdin

This is not a new subject for me, but I’m definitely having new problems with it.

I have a script that sends me a small form with some fields to enter baseball game scores. I’ve done this kind of thing before with other tasks and thought I had a solid model. Seems that now it won’t work when I use my iphone to get the form and then send the form back.

I get the d/e form on my pc and fill the 2 fields in and send it back (to a different script) to have it posted to my db. Works perfect on my PC.

Now if I use my phone to get the form that seems to work. The message that I get on my iphone when I hit send shows the post data that will be sent (why it does this I don’t know) and I simply send this message on. But the ‘posting’ script doesn’t read the data correctly. Instead of getting the post data in one line from stdin it seems to break it off at 78 chars, even tho my fgets function is now set to read 500 bytes! Of course this breaks my process since it doesn’t see all of the input data. (There’s some hidden fields in the data that make the necessary length about 150 chars.)

So – does anyone have any tidbits on why my php code seems to work just fine from and to a laptop, but not from and to an iphone? Why would the iphone uncontrollably cut an input line in half?

If you don’t follow my explanation I can try again ?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmauthorApr 20.2016 — Upon further review I have found that the iphone apparently limits lines to 78 chars as part of some archaic standard and that is what is causing my 'post string' to be broken. Does anyone know how to format my form to keep it from happening?
Copy linkTweet thisAlerts:
@ginerjmauthorApr 20.2016 — Well, a lot more research and some clever coding and I've solved this problem.

The cut-off at 78 chars involves a continuation sequence at the end of the cut-off lines. The last 3 chars of a broken line are x61, x10 and a x73 which I don't understand. By recognizing the first 2 of these 3 as a continuation indicator, I strip off the last 2 chars and begin a loop to read the next incoming line and appending it to the first one until there is no more continuation indicator in the input. In my case this involved appending two more lines onto the first one. Bingo!
Copy linkTweet thisAlerts:
@NogDogApr 20.2016 — Glad we could help. ?
Copy linkTweet thisAlerts:
@ginerjmauthorApr 20.2016 — Glad I could help make your day.

It was actually an interesting learning experience. Having had success with this message of doing quick and dirty regular d/e I was dumbfounded when this time it didn't work. From reading a bunch of posts about people having complained about the length limitations and noting in people's examples of an extra = sign at the end of their shortened-input lines I did my own testing and devised a solution. Maybe it will help somebody else here in the future.
Copy linkTweet thisAlerts:
@NogDogApr 20.2016 — There have been many times where I've started to post a question in this or other programming forums, and the act of formulating the question such that others would understand my problem actually led me to an answer, at which point I clicked "Cancel". Almost as often, 10 minutes after I hit submit, I come up with my own answer. Rubber-ducking via keyboard, I guess. ?
×

Success!

Help @ginerjm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...