I know this question is similar to other questions, I did hours of research yet I could not figure out a solution, please help me find a solution.
I want to pass textfield value from html to php textfield but instead of value, the php code is shown as output.
Page 1:
<body>
<form action="fare1.php" method="post">
<input name="address1" id="address1" type="text" size="15" value="City" />
<input name="" type="submit" />
</form>
</body>
Page 2:
<body>
<div class="content">
<h1>Instructions</h1>
<table width="200">
<tr>
<td colspan="2">
<input type="text" name="from" id="from" value="<?php echo $_POST['address1']; ?>" /></td>
</tr>
</table>
<!-- end .content --></div>
</body>
I tried using hidden fields, using javascript function and many other things but I couldn't reach a solution to my problem :(
Thanks!
Edit...
It seems I am having trouble with PHP itself, I am trying to figure it out now. PHP is not running in my system. Please let me know if you know of any free hosting sites which provides php support, I tried 50webs, it is saving the php files instead of opening it.
Thanks!
If the php is running on your server, fare1.php should execute without showing any php code for the output. If it is, then your server doesn't support the php. I suggest you download xampp. Its a free and open web server that supports php.
Related
Can anybody help explain why I can't get PHP to work when using it inline with HTML elements?
My file is saved as .php
Yes, PHP is working on my server (I'm using XAMPP)
Yes, PHP works when I use it outside of an HTML element (in a regular PHP block of code) but won't work when using it inline in my HTML
The following code is how I'm trying to implement the PHP code into my HTML. It can be found inside the first input of the form.
<li id="navHeaderItem" class="navHeaderItem headerSearchBar">
<form action="./results.php" method="get" id="headerSearch" class="headerSearch">
<input type="text" name="input" size="30" value="<?php echo htmlspecialchars($_GET ['input']); ?>" placeholder="Search E-Shout!" id="headerSearchBar" class="headerSearchBar" />
<input type="submit" value="Search" id="headerSearchButton" class="headerSearchButton" />
</form>
</li>
Just to clarify my primary objective, I'm trying to create a basic search bar which will allow users to search the content of a site I'm working on. I'm watching a YouTube video (which can be found here) and the guy in the video is doing exactly the same thing with his PHP script.... (If you skip to 8:35 by clicking here then you can see exactly how his code looks with the PHP inline.) But his works.....so I don't understand what's going on.
It doesn't help that I know very little about PHP....
Thanks in advance!
EDIT: Here is what it looks like as of right now....
Use this:
<input type="text" value="<?php echo htmlspecialchars($_GET ['input']); ?>" name="input" size="30" placeholder="Search E-Shout!" id="headerSearchBar" class="headerSearchBar" />
You need htmlspecialchars() as well because if you're not using it, a double quote in the input may break the html sytax
To resolve the "Undefined index: input..." error, you have to check if $_GET['input'] exists. If exists, print its value. If not, print an empty string:
<input type="text"
name="input"
size="30"
value="<?php echo isset($_GET ['input']) ? htmlspecialchars($_GET ['input']) : ''; ?>"
placeholder="Search E-Shout!"
id="headerSearchBar"
class="headerSearchBar" />
I'm struggling to find where I go to delete a div that is on a web page.
The page is written in php so when I go to the element inspector I can find the div and delete it but obviously that doesn't save and I need to edit it in the back end. This is where I'm stuck because I don't know where to find the bit of code I need to delete.
I'm new to php so is it a bit of code in there.
I'm trying to delete the £2.40 on this page as it displays twice.
http://chumpspotter.com/chinapalace/?page_id=5
Also im trying to delete the <.br> in the form but I don't know where its stored.
Any help would be much appreciated!
This is the code:
> </td>
> <td><span class='pricedisplay'>£2.60</span></td>
> <td class="wpsc_product_price wpsc_product_price_0"><span class="pricedisplay"><span
> class='pricedisplay'>£2.60</span></span></td>
> <td class="wpsc_product_remove wpsc_product_remove_0">
> <form action="http://chumpspotter.com/chinapalace/?page_id=5" method="post" class="adjustform remove">
> <input type="hidden" name="quantity" value="0" /><br />
> <input type="hidden" name="key" value="0" /><br />
> <input type="hidden" name="wpsc_update_quantity" value="true" /><br />
> <input type="submit" value="Remove" name="submit" /><br />
> </form>
I want to delete one of the "span class=pricedisplay" but dont know where I would look in the .php for this?
I'd suggest these solutions:
If the website is yours, or anyway if you're able to work on the page, just don't echo the span.
If you have no control over the page, you may want to use regexes, which are anyway too complex.
If you don't want to use regexes, just replace the <span class="pricedisplay"> with a span that doesn't display the input: <span style="display:none;">. This is a simple, yet powerful solution if you can't modify the page.
To delete the <.br> just open the PHP code in a common text editor and use the Find and Replace function, that's easy.
I'm new to web development and have been wrestling with this problem for several hours now, so I've decided to turn to your wisdom. I'm trying to design a little webpage with a database for my wife to store her recipes in, but I'm having trouble getting form submission to work. Here is the code for the webpage where I take the form information in:
<html><body>
Enter the information below to add a new ingredient for use in your recipes.
<form action="add_to_database.php" method="post">
Name: <input name="name" type="text" />
Serving: <input type="text" name="serving" />
Calories: <input type="text" name="calories" />
<input type="submit" />
</form>
</body></html>
And here is some silly code I've been trying to display on the page to see if I can even get the form submission to work:
<html><body>
<?php
$name = $_POST['name'];
echo $name."<br />";
?>
</body></html>
Unfortunately, the page comes back as completely back (after I hit the submit button). What's absolutely baffling to me is that I've copied and pasted the examples from this page into some files and everything seems to work fine. So it seems as though apache and php are working correctly, but I'm messing up somewhere along the way. My apologies in advance if this seems like a stupid question but for the life of me I can't figure it out.
Do you name the other file as add_to_database.php where the form is submitted. Instead you can test on teh same page by removing the add_to_database.php from the form action.
form action="" method="post">
Name: <input name="name" type="text" />
Serving: <input type="text" name="serving" />
Calories: <input type="text" name="calories" />
<input type="submit" />
</form>
and write the php code on the same page as
$name = $_POST['name'];
echo $name;
If this is not working for you. Create a php file named test.php and type phpinfo(); there.
Verify that your page is indeed being processed by PHP - obvious question, but does your PHP file have a .php extension? Do other things like phpinfo() or echo "Test"; work?
Check the error log in /var/log/apache2/error.log or similar (if on Linux, dunno where that'd be on Windows).
Try turning display_errors on in the PHP configuration (this is a good idea only for a development install, not a production server).
a bit of a longshot, but if you can verify that php is pro essing the page. Clean up your html, you are missing the dtd, head, and encoding. . hard to say how a browser is going to interpret a form (missing a name attribute) without these.
I have a php file that does a whole sleuth of user account stuff. It's purely being used to test if the features are working. However the script stops before the first feature is output. I have determined that the code is failing somewhere in this code:
...more above...
Authentication Form<br>
<br>
<?php if($this->session->userdata('authenticated')):?>
Welcome back <?php echo $this->session->userdata('userid');?><br>
<form action="<?php echo base_url();?>/account/logout" method="post">
<input type="submit" value="Log Out"/>
</form>
<?php else:?>
<form action="<?php echo base_url();?>/account/login" method="post">
Username: <input type="text" name="username"/><br>
Password: <input type="text" name="password"/><br>
<input type="submit" value="Login"/>
</form>
<?php endif;?><br>
...more below...
What i can not figure out is why this code if not executing. No errors are being outputted and i have used code similar to this before with no problem. Any help would be greatly appreciated.
One last note:
I'm using xampp running on my laptop and using codeigniter. newest of both.
The really snazzy way is to use xdebug http://www.xdebug.org/
The brute force way might be to lace your file with
echo __FILE__, ":", __LINE__, "\n<br/>";
and
var_dump(get_defined_vars());
plus also read up on setting error_reporting to an appropriate level for debugging plus show_errors in the PHP manual # php.net
I got following scenario:
A site is sending a request to a php-file to hand me some data. For this request I am selecting an item - here is the code for that part:
<form action="?modul=transaktionen&subModul=monitor" method="post">
<input type="hidden" name="suchVal" value="1">
<input type="hidden" name="action" value="1">
<!-- A LOT OF STUFF INBETWEEN ... -->
<table>
<tr>
<td>
<input type="radio"
name="hostsARR[host][idGcomp]"
id="nod_331"
value="331">
</td>
<td>Some text which is really not important</td>
</tr>
<tr>
<td>
<input type="radio"
name="hostsARR[host][idGcomp]"
id="nod_332"
value="332">
</td>
<td>more text that is not important</td>
</tr>
</table>
<input type="submit" class="sendButton" name="edit" value="Show details">
</form>
And when I select one of these item and hit the button it should send me the request with these attributes:
action 1
edit Show details
hostsARR[host][idGcomp] 332
It does that normally, but when I add javascript to it it gets totally messed up! It does not send the right request. What happens is that I do not get the hostsARR. Everything else gets through. I added a script by frequency-decoder.com for pagination and for sorting. You can find the script here if you need a look at it: http://www.frequency-decoder.com/2007/10/19/client-side-table-pagination-script.
Basically my question is whether there are known Javascripts or bugs or whatever I don't know or am not capable of giving a name for that mess up POST (or other) requests?
Seriously this is driving me crazy as I really do not see a reason why sorting a table or rather adding javascript should alter a form element to that extent.
Thnx in advance for your help.
EDIT: The request doesn't work anywhere BUT IE ... dunno where IE is maybe more tolerant?
Answering to the information given, I can conclude that the pagination or sorting script has nothing to do with what causes your error.
My guess is that your manual actions have caused this or some other included script.
But unless you provide us these no-one can tell.
If you could provide the full source to recreate the problem we could all be of more help.