//Search button for SeekingAlpha
echo '<div id="searchAlpha">';
echo '<FORM NAME="form1" ACTION="http://www.seekingalpha.com/symbol/" METHOD="POST">';
echo '<INPUT TYPE="TEXT" NAME="symbol" placeholder="Search by symbol, author, keyboard..." / VALUE="<?php echo $symbol;?> "> <INPUT TYPE="SUBMIT" VALUE="Submit">';echo '</FORM>'; echo '</div>'; //end SeekingAlpha
My question is - How do I exactly get the textfield variable to the URL?
For instance - when a user type a stock symbol into the textfield, it would type out as http://www.seekingalpha.com/symbol/$symbol where $symbol is the input from textfield
Thanks!
Related
Here is a part of my code in a PHP file :
echo '<form action="verification.php" method="POST">';
echo '<label><b>Name</b></label>';
echo '<input type="text" placeholder="name" name="username" required>';
echo '<input type="submit" id="submit" value="go" ></form>';
How can I get the input value of the form without submitting it and put it in a variable $var?
My goal : when we click on submit, it opens a window with the name of the input.
Thank you for your help
I am creating a button in php and want to call a php with parameter when clicked:
echo '<form method="get" action="./ash.php?q=Y" >';
echo '<button type="submit" >QUERY</button>';
echo '</form>';
When I click on the button, ash.php gets indeed called, but the q parameter has been 'forgotten' in the process.
How can that be?
echo '<form method="get" action="./ash.php" >';
echo '<input type="hidden" name="q" value="Y" />';
echo '<button type="submit" >QUERY</button>';
echo '</form>';
I have a register form (for events) in which the number of fields input are not same. It depends upon the events. Different events limit different numbers of members for registration. So, in my events TABLE I've a row members which store the number of members.
So,finally my registration form goes like this:
if ($row['members']>1){
echo "Hello ".$sess_name.", you can add ".($row['members']-1)." more members to register for ".$row['name']."<br>";
echo "On successful registration of the event, all the team members will receive an email on their registered email ids<br>";
$mem=array();?>
<form action="" method="post">
<?php for ($i=1;$i<$row['members'];$i++){
echo '<label>Insert ID of Member '.$i.' :</label>';
echo '<input type="text" id="id" size="20" name="'.$mem[].'"><br>';
}
echo '<button type="submit" id="submit" value="Register" name="register1">Register</button>';?>
</form>
I'm storing the ID that are being input in an array($mem)
But I don't know how to pass it ($mem) in another page to store it in MySQL table.
Add an hidden input field
<form action="" method="post">
<?php for ($i=1;$i<$row['members'];$i++){
echo '<label>ID of Member '.$i.' :</label>';
echo '<input type="text" id="email" size="20" name="'.$mem[].'"><br>';
echo '<input type="hidden" id="userID" name="userID[]" value='.$i.'>';
}
echo '<button type="submit" id="submit" value="Register" name="register1">Register</button>';?>
</form>
I am creating a faq panel for there can be multiple answers for question and i want to take the answer id .because i am storing comment by answer id
the problem is that how to sent the $answer_id to the comment_submit_process.php and how to recognize the answer ?
$selected_ques= mysql_prep($_GET['ques']);
$query = "SELECT * FROM formanswer where question_id = {$selected_ques}";
$ans= mysql_query($query);
if($ans){
while($answer = mysql_fetch_array($ans))
//here is the form
<form id="add-comment" action="comment_submit_process.php" >
<textarea class="comment-submit-textarea" cols="78" name="comment" style="height: 64px;"></textarea>
<input type="submit" name="submitbutton" value="Add Comment" class="comment-submit-button" >
<br> <?php
$ans_id= $answer['id']; //i am fatching the $answer['id'] from database
?>
<input type="hidden" name="ques" value="<?php echo $_GET['$ans_id'] ?>" />
<span class="counter ">enter at least 15 characters</span>
<span class="form-error"></span>
</form>
<?php }} ?>
You might have typo here !! it should be..
<input type="hidden" name="ques" value="<?php echo $ans_id; ?>" />
Other thing, you can add get param to action link it self.
<form id="add-comment" action="comment_submit_process.php?<?php echo $answer['id']; ?>" >
Instead of setting the ans_id, every time to the hidden field .
Generate a string of ans_id seperated with "," until while loop ends append the string and assign that value to the hidden field and in form action page you can get that value and generate van array from that string with delimiter ",".Now you can have the array of ans_id in your form action page
$answer_array = "nothing";
while($answer = mysql_fetch_array($ans))
{
if( $answer_array == "nothing")
$answer_array = $answer;
else
$answer_array .= ",".$answer;
}
<input type="hidden" name="answer_arr" value="<?=$answer_array?>">
In Form action page you can get that hidden value
$ans_array= explode(",",$_GET['answer_arr']);
You can echo answer_id in form action tag as additional parameter like this:
<form id="add-comment" action="comment_submit_process.php?ans_id=$ans_id" >
//Your stuff here
</form>
in comment_submit_process.php you can identify answer by
$ans_id=$_GET['ans_id'];
You can do further processing by using $ans_id
Edit:
change this line:
<input type="hidden" name="ques" value="<?php echo $_GET['$ans_id'] ?>"
to:
<input type="hidden" name="ques" value="<?php echo $ans_id; ?>" />
so that value of that field would be $ans_id fetched from DB.
<a href="companies.php?id='. $_GET['id'] .'&offset='. $next_offset .'"><input id="button" type="button" value="More"/>
i somehow want to send &offset=avalue but useing a input button. without the id.
how can i do the similer thing with useing form action get ?
like ( warning epic fail ) i should add a hidden input or something ?
echo '<form action="welcome.php" method="get">';
echo '<input id="button" type="button" value="More"/>';
echo '</form>';
please comment if you guys dont understand thanks!
ok somehow i have manage to make it work
echo '<form action="companies.php?id='. $_GET['id'].'" method="get">';
echo '<input type="hidden" name="offset" value="'.$next_offset.'">';
echo '<input id="button" type="submit" value="More"/></a>';
echo '</form>';
but still have an error http://local.host/networks/companies.php?offset=5, where does my get id goes ?
btw im still checking it out and thanks guys :)
and aha! it works
// MORE PLUGIN
echo '<form action="companies.php" method="get">';
echo '<input type="hidden" name="id" value="'.$_GET['id'].'">';
echo '<input type="hidden" name="offset" value="'.$next_offset.'">';
echo '<input id="button" type="submit" value="More"/></a>';
echo '</form>';
// END PLUGIN
For one thing, you can put parameter in the form's action attribute, just like you did with the link and href.
More readable option is hidden input element: <input type="hidden" name="offset" value="your_value">
Is this what you asked?
<? echo '<input type=button onclick=\'window.location="companies.php?offset='. $next_offset .'"\'>';?>