I am trying to pass a ColdFusion variable into a .PHP file. The essential gist of what I am trying to do is call on a CF variable in a .php API file. I did not know if this was even possible or not but I followed the flow of this thread: Pass a form field from a Coldfusion page to PHP
While trying to use the API it did not recognize the variable and I am pretty sure I am calling on it wrong. Any help is appreciated as always!
ColdFusion Form:
<cfform action="/stripped.php" method="post">
<label for="Search" style="color: #fff !Important;"> Variable Form PHP:</label>
<cfinput type="text" name="Variable" required="Yes" message="Please enter a Variable." class=" form-control" >
<input style="margin-top:20px;" type="submit" value="Send Variable" class="btn red-btn">
</cfform>
.PHP file Params:
$params = ["contactPhone" => '#form.Variable#', "mode" => "AUTO", "subject" => "Test 0.0", "text" => "TEST TEXT IGNORE!"];
Related
I am currently making a website where they can create their own pages and the areas where they put their information are in their own boxes. Each box is a row on my server. I want them to be able to have as many of these boxes as they want. So before I have changed the website the form looked like this
<form method="GET" action="createpage.php">
<input type="text" name="titleOne">
<input type="text" name="paraOne">
<input type="text" name="titleTwo">
<input type="text" name="paraTwo">
<button type="submit" name="button">button</button>
</form>
It also has the ability to be an image but that doesn't make a difference to what I am hoping you will help me figure out. I now want to change the form to something like
<form method="POST" action="createpage.php">
<input type="text" name="boxTitle">
<input type="text" name="boxPara">
<input type="text" name="boxTitle">
<input type="text" name="boxPara">
<button type="button"><button>
//the button above will be clicked to bring another set of inputs as seen in the two above using javascript
<button type="submit" name="button">button</button>
</form>
is there any way I can grab the whole form in one array and then split it up every 2 sets of information.
I am hoping the result would come out as something like this
$form = $_POST['(form)']
//$form would then look like this
$form = boxTitle => (aTitle), boxPara => (paragraph), boxTitle => (nextTitle), boxPara (nextParahraph)
it would continue like that for each extra time they clicked the button. Is this possible or am I going to have to rethink my design.
Thanks for any help
Here's the thing:
I put a <input type='checkbox' name='a'> in a <form action="b.php" method="GET"> but I can not get '?a=something' actually from url.
I don't know what's wrong because I use several <div>s by nesting them and also some css style and bootstrap classes.
My complete code is as below.
<form action="addfile.php" name = "fileinfo_form" method="GET">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">SHA1</span>
<span class="input-group-addon">
<input type="checkbox" id ="sha1checkbox" name="sha1checkbox"><!--I cannot get sha1checkbox's value from url -->
</span>
<input type="text" name="sha1code" class="form-control" placeholder="Sha1 Hash Code" aria-describedby="basic-addon1">
</div>
<input type="submit" class="btn btn-default" value="Submit"></input>
</form>
Your code seems to be working fine.
When the checkbox is checked, the result in the url will be addfile.php?sha1checkbox=on&sha1code=test.
If it is not checked, it will not return any value in the GET method via URL for that checkbox. Something like addfile.php?sha1code=test is returned only but if you use POST you can tell if it is checked or not in php code.
This is the normal behaviour of the checkbox in html forms. Don't be worried.
You can insert the following code in your destination file to test if the checkbox is checked or not.
<?php
if(isset($_GET['sha1checkbox'])){
echo "It is set";
}else{
echo "it is not";
}
So you do not need to worry about it appearing in the url unless you plan on using the url in some way.
Hi this is my first aplication .It is self explained code. I think I have missed out something I am trying to change some chars to other but I think I couldnt .because I am just getting a blank page
this is control.php
<?php
function donustur($karakter){
$tk=array("ç","ş","ö");
$ik=array("c","s","o");
$ykarakter= str_replace($tk,$ik,$karakter);
return $ykarakter;
}
$ad=donustur($_POST['adi']);
$mesaj=donustur($_POST['mesaj']);
echo "ad : ".$ad;
echo "ad : ".$mesaj;
?>
this is index.php
<form action="control.php" method="post" enctype="text/plain">
adi : <input type="text" value="adi" size="10" /><br />
soyadı<textarea cols="30" rows="30"
wrap="virtual" maxlength="10" name="mesaj"></textarea><br />
<input type="submit" value="submit" />
</form>
You have at least two problems.
First, see the documentation for plain text form data:
Payloads using the text/plain format are intended to be human readable. They are not reliably interpretable by computer
PHP cannot interpret form data submitted as plain text.
Remove the enctype attribute to use the default encoding type (application/x-www-form-urlencoded).
The only time you should specify the enctype is when you are including file inputs in the form, in which case you need to use multipart/form-data.
Second, a form control can only be successful if it has a name. Add a name attribute to your text input.
<input type="text" name="adi" value="adi" size="10">
Finally, even with those problems, I don't think you should get a blank page. (I don't think any of the errors are critical enough to make PHP bail out). You should get output of:
ad : ad :
If you don't, then the odds are that the file is not being processed with PHP at all. Make sure that you are:
Running a web server that supports PHP
Loading the HTML documents by pointing your browser at http://yourserver/ and not something like file:///c:/foo/bar/index.php
I cleaned it up as best I could considering I don't understand the base language. Hope this helps!
control.php
<?php
function donustur($karakter){
$tk=array("ç","ş","ö");
$ik=array("c","s","o");
$ykarakter= str_replace($tk,$ik,$karakter);
return $ykarakter;
}
if (isset($_POST['adi']) $ad = donustur($_POST['adi']);
if (isset($_POST['mesaj']) $mesaj =donustur($_POST['mesaj']);
echo "ad : ".$ad;
echo "ad : ".$mesaj;
?>
index.php
<?php
<form action="control.php" method="post">
adi : <input type="text" value="adi" size="10" /><br />
soyadı: <textarea cols="30" rows="30" wrap="virtual" maxlength="90" name="mesaj"></textarea><br />
<input type="submit" value="submit" />
</form>
?>
I know there are lots others question like this and i found 1.000 answer on the web but none of those work with my code :(
So can someone help me with how to keep email value after submit?
<form name="login-registration" onSubmit="return validateForm()" method="post" action="" >
<label>Email</label>
<input type="email" name="emailinput" id="emailinput" value ="" />
<p id="emptyEmail" class="hidden">Email field is required</p>
<p id="invalidEmail" class="hidden">Email you insert is invalid!</p>
<label>Your password</label>
<input type="password" name="pswinput" id="pswinput" value=""/>
<p id="pswMinMax" class="hidden">Password should be from 4 to 8 caracters</p>
<p id="pswLettNum" class="hidden">Password should be letters and numbers. No special caracters are allow</p>
<label>Repeat password</label>
<input type="password" name="pswrepeatinput" id="pswrepeatinput" value="" onblur="isValidPswRep()"/>
<p id="pswR" class="hidden">Your passwords is different</p>
<input type="checkbox" id="policy" name="policy" value="policy" /> <label>I agree</label>
<p id="checkN" class="hidden">You must agree to our term</p>
<input type="submit" name="submit" value="Login" />
</form>
I try to put some code like:
<input type="email" name="emailinput" id="emailinput" value = "<?php echo htmlspecialchars($_GET['lastname']); ?>" />
But that php line is just displayed inside the field input.
try using $_POST['lastname'] instead of $_GET['lastname']
1)If i am not wrong,i don't see any field with name="lastname" in your code above.
2)Use $_POST because you are posting your form data with method="post".
Assuming that your file have .php as extension and php is installed on your server i would like you to notice that you have an error because you used a POST form while when you apply value to your input field you are trying to use $_GET Further more you did not assign lastnameto any input field, so use emailinput as you apply to this field name="emailinput". You should change htmlspecialchars($_GET['emailinput']); to be htmlspecialchars($_POST['emailinput']);
So your code would look like this
<input type="email" name="emailinput" id="emailinput" value = "<?php echo htmlspecialchars($_POST['emailinput']); ?>" />
This should print your variable inside your input field
There are at least 2 problems there.
The fact that the php is displayed inline suggests that either you have wrong file extension (like the comments suggested), either file is not included in your "know how to read by php" (for lack of a better way to say it, my English is not perfect) directory.
You echo a get when you sent a post (as other answer suggested)
Also... WHY DOES YOUR QUESTION HAVE JS TAG (sorry for caps, wanted to be sure it sticks out)?
I need to simply pass a form variable into a URL variable. I suspect that it's something easy to do but I'm having a hard time finding clear steps (that aren't tons of code) online anywhere.
Here's my current form code
<form id="zip_search" method="post" action="dealers.php">
<label for="zipfield">Find a Dealer</label>
<input name="tZip" type="text" id="zipfield" value="ZIP CODE" onblur="if(this.value=='') this.value='ZIP CODE';" onfocus="if(this.value=='ZIP CODE') this.value='';" />
<input type="image" value="Submit" class="submitbutton" src="/images/submit_button.gif" />
</form>
And all I need is for it to send the browser to something like this:
http://www.mydomain.com/dealers.php?zip=55118
Thank you in advance for any help.
Update to question
Thanks to Drew and Anton's responses here's an update. Changing the input name attribute to match the URL var name (tZip to zip) along with changing POST to GET did the trick but for some reason it's adding two additional URL variables as well (&x=0&y=0). I'm guessing this is something incorrect with my PHP code as I'm not a PHP wizard by any stretch. Here's all the code:
PHP Function
<?php
function processForm() {
$zipCode = $_GET['zip'];
$url = "dealers.php?zip=" . $zipCode;
header("Location: $url");
exit;
}
?>
Form
<form id="zip_search" method="get" action="dealers.php">
<label for="zipfield">Find a Dealer</label>
<input name="zip" type="text" id="zipfield" value="ZIP CODE" onblur="if(this.value=='') this.value='ZIP CODE';" onfocus="if(this.value=='ZIP CODE') this.value='';" />
<input type="image" value="Submit" class="submitbutton" src="/images/submit_button.gif" />
</form>
URL Output Example
http://www.domain.com/dealers.php?zip=12345&x=0&y=0
Additional Related Question
How is this working if processForm() is only defined but not called anywhere else. It seems to me that the processForm() function should be in the action attribute in the opening form element. Any insight? Thanks in advance.
Change the form method to "get"
You will need to change the form method from POST to GET and also rename the text input from tZip to zip otherwise your URL will look like this:
http://www.mydomain.com/dealers.php?tZip=55118
instead of
http://www.mydomain.com/dealers.php?zip=55118