I have a iframe with a name, in this case an email address that changes from users.
I need to deal with this var:
<iframe name="asd#asd.lol" src="index.html">
index.html is a simple data form like this:
<form ENCTYPE="multipart/form-data" action="upload.php" method="POST">
<p>Upload: <input type="file" name="file1"> <br /></p>
<input type="submit" value="Upload">
</form>
I need to pass the value "asd#asd.lol" to the "upload.php" file.
Is this possible?
Is it possible for you to add a querystring parameter into the index.html file?
So:
<iframe name="asd#asd.lol" src="index.html?email=asd#asd.lol">
Then in the index.html file set a hidden variable:
<form ENCTYPE="multipart/form-data" action="upload.php" method="POST">
<p>Upload: <input type="file" name="file1"> <br /></p>
<input type="hidden" name="email" id="email" value="">
<input type="submit" value="Upload">
</form>
If this is a plain HTML file you could set the value of the hidden field with some javascript.
Then use $_POST["email"] to get the email value out of the hidden field.
<form ENCTYPE="multipart/form-data" action="upload.php" method="POST" onsubmit='$(this).append('<input type="hidden" name="iframeEmail" value="'+$("iframe[src='index.html']").attr('name')+'">')'>
<p>Upload: <input type="file" name="file1"> <br /></p>
<input type="submit" value="Upload">
</form>
Try this out ,if it wont work ,than place the iFrame and ID and find it with the ID on jQuery Selector
Related
Let's say we are making a form that we want to have on domain1.com and we want to post it to domain2.com. Can this be done?
<form method="post" action="domain2.com/receivepost.php">
<input type="text" name"text" />
<input type="submit value="submit" />
</form>
domain2.com/receivepost.php
<?php print_r($_POST); ?>
You need to specify the full URL (including protocol) in the action attribute of your form tag as follows:
<form method="post" action="http://domain2.com/receivepost.php">
<input type="text" name="text" />
<input type="submit" value="submit" />
</form>
On the PHP side, you can check for POST data as follows:
if (isset($_POST['text'])) {
echo $_POST['text'];
}
Notice that the name attribute of the input tag is text.
You need to specify full URL if you want to send request to specific domain
<form method="post" action="http://domain2.com/receivepost.php">
<input type="text" name"text" />
<input type="submit value="submit" />
</form>
Or you can send to relative (for your domain) path:
<form method="post" action="receivepost.php">
<input type="text" name"text" />
<input type="submit value="submit" />
</form>
I tried all but no form is working with method or simple action like http://google.com `
<form action="http://google.com" method="post">
<input type="text" />
<input type="submit" />
</form>
even this is not working
use this
<form role="form" action="http://google.com" method="post">
<input type="text" name="text" />
<input type="submit" name="submit" />
</form>
role attribute for FORM
name attribute for input
In PHP, $_POST always accept name attribute from form elements:-
You need to write
<input type="text" name='name_of_your_field' />
instead of
<input type="text" />
You need to refer this Link.
for the life of me cant remember how i should be doing this / if its possible.
I am creating a form that takes the user to another page but want to pass the value of the text box in the url.
so e.g:
<form action="newadvert.php?vrm=" class="newadvertform" method="post">
<input type="text" name="carvrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
How can i send the user to newadvert.php?vrm= THE ENTERED TEXT HERE
I need this to then get value on the next page.
Use GET method
<form action="newadvert.php" class="newadvertform" method="GET">
And rename carvrm to vrm
<input type="text" name="vrm" class="carvrm"/>
Use the GET method and rename carvrm to vrm.
<form action="newadvert.php" class="newadvertform" method="GET">
<input type="text" name="vrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
When submitting the form, it'll go as http:///newadvert.php?vrm=
<form action="newadvert.php" class="newadvertform" method="get">
<input type="text" name="vrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
change your form method from post to get
Like this:
<form action="newadvert.php" class="newadvertform" method="get">
<input type="text" name="carvrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
you can get input value by :
$_REQUEST['carvrm']
or change input name to vrm :
<form action="newadvert.php" class="newadvertform" method="get">
<input type="text" name="vrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
now you can get input value by :
$_REQUEST['vrm']
doc: http://www.w3schools.com/PHP/php_forms.asp
I have this problem when I'm using PHP5/HTML on Apache-Tomcat6.
Here's an example for one of the forms I use in my site:
<form enctype="multipart/form-data" method="post" action="hello.php" >
<label>Title* :</label>
<input type="text" name="title" />
<label>Image:</label>
<input type="file" name="image" /><br />
<input type="submit" value="Add"/>
</form>
Whenever I add the 'enctype' attribute to any form; neither the $_FILES['image'] is returned nor the $_POST variables. As long as the 'enctype' is not there, everything (except for the file input of course) works as expected. Can any one guide me please?
You won't be able to post data with a method of get on your form.
In test.html:
<form enctype="multipart/form-data" method="post" action="hello.php" >
<label>Title* :</label>
<input type="text" name="title" />
<label>Image:</label>
<input type="file" name="image" /><br />
<input type="submit" value="Add"/>
</form>
In hello.php:
<?php
print_r($_POST);
print_r($_FILES);
Depending upon your server configuration, this will combine $_GET, $_POST, and $_COOKIE, but you'll still want to post with file inputs.
print_r($_REQUEST);
<body>
<form method="post" action="xx.php" >
Enter Title of the Post<INPUT type="text" name="title">
<br/>
Enter Description
<textarea rows="10" cols="50" wrap="physical" name="post">
</textarea><br/>
<input type="Submit" value="Post">
<br/><br/>
<form enctype="multipart/form-data" action="xx.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
Choose a file to upload: <input name="uploaded_file" type="file" />
<input type="submit" value="Upload" />
</form>
How Do I get the user to write the text and browse the image, only after which pressing a single button would both upload the text and the file?
You can't submit two forms with the same button. You'll need to combine the two fields into a single form.
You can move the file input to the first <form> (which btw, you haven't closed) and use javascript to check if text has been entered and file has been selected.
Don't nest your form tags (It's invalid HTML). You can place all the inputs in one form so they are posted together.
e.g.
<form enctype="multipart/form-data" action="xx.php" method="post">
Enter Title of the Post<INPUT type="text" name="title">
<br/>
Enter Description
<textarea rows="10" cols="50" wrap="physical" name="post">
</textarea>
<br/>
<br/>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
Choose a file to upload: <input name="uploaded_file" type="file" />
<input type="submit" value="Upload" />
</form>
Oh, as a sidenote, you may not want to use a name like "post" in your input control.