Why I'm getting the GET method? - php

I have a simple html code with this form:
<form id="check-user" class="ui-body ui-body-a ui-corner-all" data-ajax="false" method="post" action="./second.php">
<fieldset>
<div data-role="fieldcontain">
<label for="username">Enter your username:</label>
<input type="text" value="" name="username" id="username"/>
</div>
<div data-role="fieldcontain">
<label for="password">Enter your password:</label>
<input type="password" value="" name="password" id="password"/>
</div>
<input type="submit" data-theme="b" name="submit" id="submit" value="Submit">
</fieldset>
</form>
In any browser, even in my phone with the previously code it works fine when I push the submit button, on my php server log it appears
"POST /test/second.php HTTP/1.1" 200 699 ...
and I can get the POST variables in php.
Next, this html code I send it as an email (gmail), and If I push the submit button, on gmail on my desktop browser works fine :)
But If I open this email, through my phone (gmail app for iphone, also android I've tried) I get this from the php server log
GET /test/ HTTP/1.1" 200 1546 ...
Why I'm receiving a GET as the method?? Or how can I make better requests from mobile devices ???
Someone else have to deal with this before ??
Thanks for any answers about this.

I think you may find that forms are not recommended to be embedded in to emails. Most web-based email platforms do not support form functionality. You're best to provide an external link to your form.

Thanks for your response, I've ended using an external link using mailto.
I've also have to say that the reason I was getting a GET response is because the apps in a mobile phone are know as hybrid, they are not fully html, so they have security policies when one calls to another app (which is this case).
In my php i was receiving a GET method, cause the app was just opening the url, which by default is a get...
Thanks you.

Related

Html form for emails. Emails go to text or word file on an ipad

I am trying to have users use an HTML form to input their email addresses but I would like the addresses to go to a word doc or notepad or a text file on the iPad pro they are entering this all on.
I'm trying to figure out the best method to do this as I'm not using a hosted server.
So far this is what I've been using in my HTML file:
<form action="" method="post>
Name:
<input type="text" name="name">
Email:
<input type="email" name="email">
<input type="submit">
</form>
Can you tell me if I need to incorporate PHP or tell me how to do that? I've tried using POST but kept getting 'Post method not allowed' and if I tried to use GET, I would get an internal server error.
Any help would be greatly appreciated!

Success/Error messaging for PHP form submission using hidden iFrame?

I have a form on my site that I would like users to be able to submit without the page reloading. I found this answer which solved that part of it for me, but now I am trying to figure out how I would add success/error messaging to the form upon submit.
Here is my form code:
<iframe name="submit" style="display:none;"></iframe>
<form method="post" action="submit.php" target="submit">
<input type="text" name="firstname" placeholder="First name" />
<input type="text" name="lastname" placeholder="Last name" />
<input type="text" name="email" placeholder="Email address" />
<input type="submit" name="submit" value="" />
</form>
How can I determine whether the form was submitted successfully or not and display a success or error message based on the result? Also open to other suggestions for submitting the form without the page reloading.
To clarify what other commenters are already saying or have said:
The source-code in your original post consists only of a vanilla "form submit," which will be dutifully carried out by the browser just as things were done when HTTP was first invented: "the data will be submitted to the host, and whatever the host returns will be displayed as the 'next page.'" In this scenario, the role of the web-browser is totally passive.
Very commonly today, a technique called "AJAX" is used: instead of just "submitting the form" when a button is clicked, the submit-button causes a JavaScript subroutine to be run, and it (using an "Asynchronous HTTP Request" = "XHR") both submits the data to the host and intercepts the host's response. The role of (the JavaScript now being executed by) the web-browser is now active.
The host, in turn, now ordinarily does not return "displayable HTTP text." Knowing that it's being talked-to by another computer program, it instead sends that program something that can be very-easily consumed. The host typically sends "a data structure," which is ordinarily formatted in a format called "JSON."
... and, today, there are legions of great JavaScript libraries that can "make this a piece o' cake." (JQuery is only the most-popular one.)
Therefore, "surf over to some of these web sites, and take a look at their examples." (They not only supply the working demonstrations, for your amusement and amazement, but they show you on-the-spot exactly how it's done.)

Getting log in information - how does this code work?

I found a similar question here that someone wanted to create a user account loggin similar to this, but it lead me to believe it has to be all done in php in order to handle it and put into a MySQL database. From my understanding this isn't php and it is on the main html website.
How is the data captured and then stored on a database with this code then?
This is taken directly form http://cardoneuniversity.com/
<span class="dominate-and-login-form-text">Already a member?</span>
<form action="https://login.lightspeedvt.com/actions.cfm?lg=447&v=35" method="POST">
<input type="hidden" name="action" value="login">
<div class="form-group username-field">
<label class="sr-only" for="exampleInputUser3">Username</label>
<input name="username" type="text" class="form-control" id="exampleInputUser3" placeholder="Username">
</div>
<div class="form-group password-field">
<label class="sr-only" for="exampleInputPassword3">Password</label>
<input name="password" type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
</div>
<button type="submit" class="btn btn-default login-univ-btn">Login</button>
<br>
<i>Forgot Username/Password?</i>
</form>
If I seem like nothing more then an uneducated lost programmer, can you care to send me in the direction to learn?
I'm trying to create a learning/course website like this one.
Actually this form is processed by ColdFusion. ColdFusion does a similar job to PHP where it is a server side scripting language. Here is a good tutorial that will teach the basics of a login system using HTML, MySQL and PHP.
User Membership With PHP
For a more advanced and secure tutorial check this out:
How to Create a Secure Login Script in PHP and MySQL

Email contact form without PHP

I'd like to use a contact form for a website I'm creating, but PHP is not an option since the client doesn't wish to use it. Is there a clever way to work around this somehow, by sending email parameters (which is non-standard) perhaps, or by using an external contact form? Are there any good ones that don't use advertising and are easily modified to a different language for example?
Thank you.
Check out formspree.
https://github.com/asm-products/formspree
For action you simply put:
<form action="http://formspree.io/you#email.com" method="post">
<input type="text" name="name">
<input type="email" name="_replyto">
<input type="submit" value="Send">
After verifying your email after the first send this will email you the contents of the form. One thing to keep in mind is that this will take the input names. If you do not include input names it won't send you that form field.
There are hundreds of embeddable (most likely iframe-based) solutions for contact forms, which would enable you to get around using a server-side language like PHP. Just a quick google search will give you some.
Alternatively, you could make a form in HTML, and have a submit button which is actually a mailto: link, and you modify the parameters of that mailto as your form inputs change.
The only downside of this is that it's not as convenient for the user, as it then opens up their email client and they have to actually send it.
Personally, I would try and persuade the client, but if that isn't possible, then those are your options.
Check out www.enformed.io.
Has a couple of interesting options that formspree does not have( Like redirect out of the box, and a html email editor).
I used Formspree but formspree doesn't allow ajax unless you have Gold Version. It doesn't work on the basic so I am planning on making an account on enformed.io. I still haven't used it but I have heard that t is very good. You can also use alerts fro success and error messages.
<form style="margin-left: 6%;" class="email" action="https://www.enformed.io/YOUR_TOKEN" method="post">
<p>Name:</p>
<input type="text" name="first_name" />
<div id="margin" style="height: 0.5%;"></div>
<p>E-mail:</p>
<div id="margin" style="height: 0.5%;"></div>
<input type="text" name="email" />
<div id="margin" style="height: 0.5%;"></div>
<p>Subject:</p>
<div id="margin" style="height: 0.5%;"></div>
<input type="text" name="subject" />
<div id="margin" style="height: 0.5%;"></div>
<p>Message:</p>
<div id="margin" style="height: 0.5%;"></div>
<textarea name="message"></textarea>
<div id="margin" style="height: 0.5%;"></div>
<button type="submit" class="btn btn-default">Submit Form</button>
</form>
Would something as simple as a mailto form work?

How do I send mail from a static website .htm to a php server on a different website?

I am currently working on a project where the site is static and the server does not have php installed or anyother dynamic server side language. I've noticed companies like uservoice that somehow get data from a static website to their servers. How can I create a contact form on my static 'no php server' web site and get that contact form data to another server that has php enabled and then send that data with the phpmail function to the specified email address?
simply set the action attribute for your form to point to the other server:
<form method="post" action="http://example.com/process.php">
<input type="text" name="my_textfield" />
<input type="submit" value="send!" />
</form>
Use the form action to send to the capture server:
<form action="http://myphpserver.com/contact.php">
You can use a service like usebasin.com to submit your form to. In other words, setup your form as you usually would, and just point it to your usebasin.com account form like so:
<form action="https://usebasin.com/f/{endpoint-id}" method="POST">
<label for="email-address">Email Address</label>
<input type="email" id="email" name="email" required>
<button type="submit">Submit</button>
</form>
Here are some docs as well: https://usebasin.com/docs

Categories