I have a very basic question. Please consider a site with subdomains:
MAIN SITE: www.domain.com
Sub-domain 1: sub1.domain.com
Sub-domain 2: sub2.domain.com
The main site, in http://www.domain.com/index.php, has a form:
<form action="http://sub1.domain.com" method="post">
<input type="text" name="userInput">
<input type="submit">
</form>
Will the data be posted to http://sub1.domain.com and be accessible by the following: (?)
<?php
$input = $_POST['input']
//the goal is to make $input, a variable in http://sub1.domain.com/index.php
//equal to what the user submitted in the form at http://www.domain.com/index.php
?>
I simply need to load sub1.domain.com/index.php with the posted variables present, no real-time fanciness. From my reading, I've determined there may be a setting which blocks this activity in apache or some other application, but theoretically, data should be able to be sent to any domain/subdomain from any domain/subdomain using POST, correct?
**> Step1: Go to Cpanel select Subdomain icon and click on manage
redirection link of your subdomain. and set redirection to
http://sub1.domain.com/xyz.php and save setting
Step 2: Changes in form as below
Step 3: Changed in xyz.php which must be located in inside sub1
directory
sub1 | |__xyz.php
xyx.php file
**
Related
I keep getting a 404 error when trying to submit this form. In my website directory i have a folder called mobile, which inside has forms.php and process.php.
The form is located on this page
http://localhost/mobile/forms.php?ft=0&id=2
here is the form
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
//details
</form>
When i try to submit i get a 404 error, when it should go to http://localhost/mobile/process.php?o=9&ft=0? How do i fix this?
By looking at the URL's what I conclude is that both the php files are on the same page so change your action url from
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
To
<form action='process.php?o=9&ft=0' method='POST'>
A forward slash before the mobile means it selects the folder from the root.. So you probably don't need that here.
Last but not the least, be sure the file names are proper, and also make sure the cases are same, because the file names are case sensitive.
Note: You may also get 404 error if you are using header('Location:
xyz.php'); on the form processing page, for redirecting the user to
some page after the form processes and you may encounter 404 because
the page on which the script has redirected doesn't exist. so make sure
that the URL is correct if you are using header()
Try changing
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
to
<form action='process.php?o=9&ft=0' method='POST'>
Since they are in the same directory.
You can't pass a GET parameter in the form action.
In order to pass parameters, you will have to create a hidden input like :
<input type="hidden" name="o">
I have this simple html form :
<form action="../../process.php" method="POST">
----SOME INPUT HERE----
<input type="submit" value="Submit">
</form>
and that form located under this folder : /public_html/userweb/subdomain.domain.com/form.php while the process.php is located under /public_html folder.
the problem is... /public_html/userweb/subdomain.domain.com is actually a sub-domain's root folder and /public_html is the TLD's root folder.
my question is can a HTML form submission in sub-domain process by TLD? if so, how to do it? because that form always search process.php under subdomain.domain.com/process.php not domain.com/process.php
A form action can be any url. For example, this form submits a search query to google:
<form action="http://www.google.com/">
<p><input name="q"></p>
</form>
To do what you describe, just use a full url as your action, such as //domain.com/process.php
The action of the form could be any URL, but not the path in the server.
You just need to set the action like:
<form action ="//domain.com/process.php" method="post">
AJAX it to the domain you want to send it to, and send it as jsonp.
Edit: I was thinking of the Same Origin Policy, where you are restricted in what datatypes you can transmit cross-domain.
There are many similar questions on the same. I have tried to look far and even tried using the comments and suggestions provided for the similar questions but I am stuck. I can't achieve what I want to.
Both domains are owned by me (Abc.com and xyz.com) and I have full right/access on them
User Enters Name, College, Amount in a form on Abc.com
I need to post the result to xyz.Com/abc.php
Notify user " Being redirected to xyz.com for further process"
Redirect the user to xyz.Com/abc.php
On xyz.Com/abc.php, User is showed the posted values (received values from Abc.com)
These are the things I tried and came to know:
I know curl is for posting only, it can't redirect
Header() redirects but post?? I think No.
Using session variables work on same domain not on domain to domain
What should be the process to achieve this. There ought to be some way to achieve this.
Try something like this on abc.com:
<script type="text/javascript">
function redirectWarn() {
alert("Now redirecting you to xyz.com for final processing!");}
</script>
<form method="POST" action="xyz.com/abc.php">
<input type="text" id="name" name="name">
<input type="text" id="college" name="college">
<input type="text" id="amount" name="amount">
<input type="submit" id="submit" name="submit" onclick="redirectWarn();">
</form>
Then when the user clicks submit, the alert tells them they are being redirected to xyz.com/abc.php. In that file on that server (xyz.com/abc.php) you need to get the user data by inserting this PHP at the top of the file abc.php:
<?php
$name = $_POST['name'];
$college = $_POST['college'];
$amount = $_POST['amount'];
?>
Please make sure that you use some kind of javascript on abc.com or PHP on xyz.com to make sure that the user has entered data into your form fields before they get redirected. Also, if you are going to put these values into a database query or otherwise use them elsewhere, promise the internet that you will sanitize these values so your site won't get hacked and turned into a malware distribution center. :)
I developed a web crawler to search for certain tags on my companies websites to make sure they are live, have Google analytics, blah blah. However, my company has close to a hundred websites so the actual crawl process, is literally a crawl. So I wanted to create a form where the user inputs a web address of one of our companies and it only crawls that one website. I am not good with forms, so what I basically want the form to do is store the url the user inputs then redirect to a different page where the url is given to the crawler and the results are shown.
Here is basically what I have so far, not much, I am having trouble redirecting to a different page and storing the URL variable so I can pass it to the crawler code that I have.
<div id="main-content" class="mc-left"> <div class="entry"> <div style="position:absolute; margin-left:520px; height:25px; width:120px; font-size:10px;"> </div>
</div>
<h2><?php the_title(); ?></h2>
<form name="form1" id="form1" method="POST" action="submitcrawler.php">
<div class="hiddenfields">
<p>Website Address:<br>
<input name="websiteaddress" type="text"></p>
<input type="submit" class="submit" name="submit" value="Submit">
</form>
As you can see I want this form to bring me to submitcrawler.php, however, when I create that php file, when I hit submit it brings me to the current slug (../crawler-2/submitcrawler.php instead of ../submitcrawler.php) so it throws up a 404 error
The form is submitting to 'submitcrawler.php' in the same folder as the file that you're looking at, so if its in /crawler-2/ then that's where its looking.
Use ../ if you want to ascend to the directory above, or probably better, use / and enter the path to the file from the web root (the top directory viewable by apache / the web server).
So
<form action="../submitcrawler.php">
or
<form action="/submitcrawler.php">
For the functionality that you're looking for, you could try using method="GET". That way, you can see the information that is being passed to the other PHP script in the URL.
Then simply retrieve the information in the other PHP script:
if(isset($_GET['websiteaddress'])) {
$websiteaddress = $_GET['websiteaddress'];
} else {
echo "No web address was received.";
}
In terms of the form action attribute, you need to use an absolute path if the scripts will both be static, otherwise if the scripts are dynamic and may change locations on the servers, then use relative paths.
Path Info:
http://en.wikipedia.org/wiki/Path_%28computing%29
http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm
If the file you're talking about is under crawler-2 directory it will submit the form to that file unless you use a relative path ../submitcrawler.php
The action you have set on that form will send it to submitcrawler.php in the same directory as the current script. Try changing the action to ../submitcrawler.php, or alternatively set it to the absolute url of the script (http://mydomain.me/submitcrawler.php)
You used a relative path in your post action value. If for example your crawler script is in your webroot you should use action="/submitcrawler.php". If not you can do something like action="/path/to/submitcrawler.php"
I have a CodeIgniter project with a very simple test application.
Controller opens a view (PHP page) which has a text box and a submit button.
When I press the submit button, instead of redirecting to the appropriate function call in the controller, I get redirected to localhost/xampp.
here's the code on my view, which SHOULD be redirecting to the save_genre function in the controller named "welcome".
<?php echo form_open('welcome/save_genre');?>
<label for="radio_genre">Radio Genre</label>
<input type="text" name="radio_genre" id="radio_genre"></input>
<?php echo form_submit('submit','Save'); ?>
</form>
any ideas what could be wrong? I think it's not the code but is a setting or file wrong somewhere, but i don't know where to start looking.
EDIT:
I had already redefined the base URL in the config file.
I don't think I rewrote the .htaccess - but I'll certainly check. (This is a team project setup and I'll make sure no one else has done that.)
As requested, below is the HTML output by the form. The URL link for the form seems very odd to me because it doesn't mention the project name like I would expect. So there are two places for me to look now. Thanks!
<body>
<h1>Welcome!</h1>
<form action="http://localhost/index.php/welcome/save_genre" method="post">
<label for="radio_genre">Radio Genre</label>
<input type="text" name="radio_genre" id="radio_genre"></input>
<input type="submit" name="submit" value="Save" />
</form>
</body>
EDIT: OK - I recreated the project myself and then brought my PHP files in and it works fine. So the person who created the project did something odd.
You need to edit $config['base_url'] in /system/application/config/config.php.
Somehow, while the index.php file was there in the file system, it wasn't being recognized as part of the project. Once I copied a new index.php file in there (identical file but it trigger the sense that "this changed.), I then went back into my project and refreshed and saved.
Everything then worked.