Saving HTML input data to XML - html

I've searched through the forum and couldn't find a specific answer on my troubles.
What I want to do, is having a simple form, where a user can input information and then, when a button is pressed, get it saved on the server. And if its possible get the XML document saved with the name that specified in the first field.
I need to pull out the information in an app written in action script. Which is, sad to say, the only language I know properly.
I'm trying to get my information from this form (it should be bigger, but right now, I just need a working example):
<form action="" method="post" class="form">
Name: <input type="text" id="name" name="name">
<br>
Activity: <input type="text" id="activity1" name="activity1">
<br>
Activity: <input type="text" id="activity2" name="activity2">
<input type="submit" id="btnSub" name="btnSub" value="Save">
</form>
To be saved in a XML document.
And as said, everything is going to be on the server. If it helps anything.
I can't use ASP as one.com doesn't support this. :/
Hopefully some of you are able and willing to help me out.
I'll try to answer everything thats unclear.

This may be of help:
http://www.hardcode.nl/subcategory_1/article_431-xml-to-string-and-string-to-xml-in-javascript
You can then use an AJAX call in jQuery to send the data to PHP to save it if that is what you are needing.
EDIT: However, I do feel that it is much easier for this to be done server-side. I'm not great with PHP but it's very simple in .NET (unfortunately you explained you can't use this option).

Related

Get is being stripped off an HTML form

I have an HTML form on a page. The method is POST, but I'm manually adding a GET parameter to the URL string depending on which button the user clicks. But when the form is submitted, the GET is being stripped off the URL.
I'm really baffled by this. This method has worked many times in the past, and this actual form itself used to work fine. Suddenly, the exact same (formerly working) code doesn't work.
I'm using Firefox Web Developer tools to look at which parameters are passed in the request, and there's no sign of the GET.
<form method="post" target="_blank">
<input type="hidden" name="report" value="abc">
...a couple Select form fields...
<input type="submit" action="reports.php?format=PDF" value="Go">
[<input type="submit" action="reports.php?format=preview" value="Web Preview">]
</form>
Basically, if they click "Go" they should get a PDF, and if they click "Web Preview" they get the same report as a web page; but the "format" parameter isn't received on the processing end of things.
(I've also tried it in multiple browsers.)
Edit to add: I can confirm that the POST data is being received on the processing end. Only the GET is missing.
Edit to add:
If I move the action to the <form> tag, it works. Of course that prevents me from having two buttons that do two things, so it doesn't solve the problem, but it's a clue to what might be happening. This DOES work:
<form method="post" action="reports.php?format=PDF" target="_blank">
<input type="hidden" name="report" value="abc">
...a couple Select form fields...
<input type="submit" value="Go">
<!-- [<input type="submit" action="reports.php?format=preview" value="Web Preview">] -->
</form>
The first place I would look would be to verify that the data is indeed being sent as a POST request. If, for any reason, the browser thinks the form should be using a GET request, it will quite happily delete and replace the hardcoded query string.
What I would suggest is doing a var_dump() on $_POST and $_GET in reports.php to get a definitive idea of what the browser is actually transmitting. There may be some clues in the output.
If the $_GET data is truly missing, I would then check to verify that no one has put a rewrite rule into place on the server to strip query strings off of PHP requests, or even requests to this specific page. As far as I am aware IIS does not normally strip query strings from POST requests, as this would go against well established standards, but it is always possible that rules were manually added to accomplish the same thing.
Solved -- In a submit <input>, an "action" attribute is invalid. I should have used "formaction":
<input type="submit" formaction="reports.php?format=PDF" value="Go">
Somewhere along the way an update to various web browsers must have stopped accepting "action".

HTML website programming

I am starting a new business and am creating a basic website for displaying what it is about and its products.
I have started with an outline in HTML and CSS, but I have met on some trouble with adding submitting forms and adding a path to the links.
I have figured out how to make a basic form like this:
<form>
First name:<br>
<input type="text" name="firstname">
<br>
E-mail:<br>
<input type="text" name=„E-mail“>
</form>
But whenever I click the submit button the page gets an error and I am also not sure where the data would be stored. I have not yet set up the domain for the website so I am still doing this in my browser.
Also if I want to have a link to another page on my website such as:
Learn More
how do I add the path to the next page?
Thanks in advance!
You need to learn first how html works, and how to receive data with a server-side language (like php, java, asp, nodejs, etc).
To put a target to the form make something like this:
<form action="your-target-page.php" method="POST">
If you have a php server you can receive data:
$email = $_POST['email']
Learn more about form tag:
https://developer.mozilla.org/es/docs/Web/HTML/Elemento/form
Regarding the form you are going to need a server side language to handle the posting of a form. If you are new to website creation I would suggest using Wordpress and an already made free theme.
For your form this is better markup:
<form>
<label>First name:</label>
<input type="text" name="firstname">
<label>E-mail:</label>
<input type="text" name="email">
</form>
Assuming you have a file called learn_more.html in the same root that is how the link would work, target="_blank" opens it in a new browser window, if you just want it in the same window omit this.
Learn More
HTML form doesn't store any data with itself. It can just send a formed data to a server via HTTP protocol.
You need to have any kind of server side (CGI) program. Those are usually programmed in Perl, Python, Ruby, Java, PHP or so on.
In short
Send data to server side program from HTML form
Receive and process data with the program.

type email in safari

I have a form:
<form action="something.php" method="POST">
<input type="email" name="email"/>
<input type="submit" value="Send Email"/>
</form>
When someone tries to input some string that is not in email format the form won't let him. The only problem is that this dosen't work on Safari! Why!!!! http://www.w3schools.com/html/html5_form_input_types.asp
So what super easy work around can I use? Thank you
Let's be very clear on this point: while some HTML clients will respect the input type, several won't, and even if they do, it will not prevent anyone from forging an HTTP request where this field is not an email address. Therefore, you can rely on <input type=email> to provide a hint to users as to what should go in that field, but you shouldn't rely on it to make sure that only email addresses make it to your PHP script.
So some browsers support it, but Safari doesn't. That's pretty much all there is to it.
The correct solution, then, is to also do server-side validation and make it fail if it's not an email address. You can relatively easily check that with regular expressions.

Angular.js submit form old way

I'm migrating an old html page from jQuery to Angular, and it contains some old-school forms with <input type="submit">. When I enriched my pages with the ng-app directive, the old forms stopped working (I mean when you press the submit buttons then nothing happens).
I searched for this problem and scanned the Angular docs too, but it seems that nobody is submitting forms anymore.
Any suggestions on how to bring those forms to life again without much keystrokes would be appreciated.
Currently the form has following markup:
<form name="form_upload" method="post" action="" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="send" value="Upload">
</form>
All jQuery code I purged and starting fresh with Angular.
UPD:
I guess i now found cause, it's empty action attribute, it seems empty action is not welcomed by standarts, but very convenient to use allowing you to submit form to the current page URL, is there Angular way to do it ?
Going off of the docs: http://docs.angularjs.org/api/ng.directive:form
Angular's philosophy is to minimize data and page reloads, so they don't like "old school forms", but you can get around it by using an action attribute in the form.
Angular is designed with single page applications in mind and avoiding full page reloads as that is going to take longer to do. By using the ngSubmit directive, you can define a function to send over the form data to the server and get a response back much quicker than a full page reload. Bytes instead of Kilobytes.
Use a non-empty action attribute to make Angular submit the form
Fill action attribute with current location (using angular)
In your controller:
$scope.location = $window.location.href
In your HTML:
<form action="{{location}}">
See the plunkr demo.
I've done this. I'm pretty sure I was using jquery to submit the form, but you could probably do it with plain old javascript.
One of the comments on the angular form page suggests this:
<input onclick="javascript:$(this).parent().submit();" type="submit" value="">
http://docs.angularjs.org/api/ng.directive:form

html5 Input type=email Not Appearing in request.form collection

Using classic ASP (vbScript) on iis7:
I am trying to upgrade a front-end web form from XHTML to HTML5 tags.
I have been successful in all but one place - that is, with:
<input type="email" value="name#email.com" name="myEmail" />
<input type="text" value="some name" name="myName" />
The issue is that when posting the form to a .asp script which loops through the request.form collection, the input from the type="email" form item is not present in the collection. The item just doesn't exist in the collection.
Does anyone have any experience with this?
I figured it out. My issue was actually with the .js code which first accepts the input from the form (and then passes it to the .asp page for processing) in an ajax-style manner.
There was some hardcoded input types in the js and it had not been updated to accept the html5 data types.
Thanks to anyone who took the time to look at the question.