Finding and deleting DIVs, page written in php - php

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.

Related

PHP won't work inline with HTML elements

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" />

User input not showing in search form

I have a free form search that I moved from my main content to my header. Once I moved the form into the header the text inside of it stopped showing. The placeholder works but when you begin typing it is completely blank. The search and the functionality work perfectly, I just cannot see what I am typing. Any ideas?
<form class="search" action="/all-results/" method="get">
<fieldset>
<span class="text"><input name="searchProducts" value="All" type="hidden">
<input type="hidden" name="search_selection" value="all">
<input name="byString" id="s" type="text" value="" placeholder="<?php echo __('Search','Avada'); ?>" /></span>
</fieldset>
<form name="input" action="/all-results/" method="get">
<input type="submit" id="search_button" value="Search">
</form>
</form>
Your HTML is invalid. You can not nest a <form> element inside another <form>. Messing up forms and tables are two of the best ways to produces peculiar browser behaviour, so my guess is that this is your problem.
If you correct your HTML (validate it!) and the problem persists, then post a minimal HTML page with CSS so that there is something for us to debug.

HTML Forms to query multiple pages

i am trying to build a meta search engine.
I currently have the following code.
<form method="POST" action="google_basic.php">
<label for="service_op">Service Operation</label><br/>
<input name="service_op" type="radio" value="Web" CHECKED />
Web <input name="service_op" type="radio" value="Image" />
Image <br/> <label for="query">Query</label><br/>
<input name="query" type="text" size="60" maxlength="60"
value="" /><br /><br /> <input name="bt_search" type="submit"
value="Search" /> </form> <h2>Results</h1>
{RESULTS}
I need the form to have more than one action= ""(I realise a form can only have one action, i need the equivalent of 3 actions ="" ). The form needs to access 3 search engines and display the results. What is the best way to do this?? I know that javascript may an option but is not a solution for me as it may be switched off in the clients browser.
Any ideas on the best way to go about this??
TIA
You need to perform the 3 "actions" on the server (in or from the google_basic.php file). After POSTing to the server, you can perform an arbitrary number of "actions" from there.
See also: http://us2.php.net/manual/en/intro.curl.php
it only needs one action, then the action is what will display all 3 searches. so instead of having google_search.php, bing_search.php, and yahoo_search.php, combine them all into a generic search page that will display all 3

pass several parameters to php using js

I have some problems when trying to pass some parameters to PHP via JS.
Here's the situation:
HTML:
<form id="numbtns" method="post" action="imphp.php">
<button id="1" onClick="pass(this.id)">1</button>
<button id="2" onClick="pass(this.id)">2</button>
<button id="3" onClick="pass(this.id)">3</button>
<button id="confirm" onClick="save()">submit</button>
</form>
JS:
pass(clicked_id) {
var btn = document.getElementById(clicked_id);
**// I have no idea what to do next to give the ids to the php file.**
}
save() {
**// I want function save() to collect the parameters from function pass(), and pass them to 'imphp.php' when submit button is clicked. I'm stuck here.**
}
PHP:
// connection part, let's skip it.
...
$num = $_POST['num'];
$query = sprintf("SELECT id, num FROM tb WHERE num = $num");
I know maybe it's a quick and stupid question for u, but I cannot figure it out for hours. So... could anyone help me out, I'd be very appreciate that.
Thx in advance.
I don't think you need Javascript for this. All you want to do is post the form to the PHP page, right?
<form id="numbtns" method="post" action="imphp.php">
<input type="radio" name="num" value="1" /> 1<br />
<input type="radio" name="num" value="2" /> 2<br />
<input type="radio" name="num" value="3" /> 3<br />
<input type="submit" value="Save" />
</form>
Using buttons made no sense to me at all, so I changed them to radio buttons. The user will check one, then click the Save button to submit the form.
You need to use AJAX... i would recommend simplifying the process with a javascript library like jQuery... here is a tutorial using jQuery / AJAX / PHP: http://www.php4every1.com/tutorials/jquery-ajax-tutorial/
This is a very frequently asked question in one of several forms, as you can see by looking under the Related heading to the right on this page.
I see this a lot and there seems to be a fundamental flaw in many people's understanding of how PHP and Javascript work, so I wanted to throw this out there.
PHP runs on the server, executing the code in the .php page and modules there, and produces output which is sent to the browser. PHP is now done. Stopped. Fini. You PHP code is no longer running.
The web browser receives the output, builds the DOM tree, and starts rendering the HTML as a page and executing the Javascript. The Javascript can't pass parameters to the PHP because the PHP is no longer running. It has terminated execution. Kaput. In addition, the Javascript is running in the browser, on the client machine, while the PHP runs on the server.
What you can do is invoke some new PHP (or re-invoke the same PHP code to do something else) and that is usually done be making an AJAX call from Javascript, as #Jeffery A Wooden suggests in his answer.
HTML, though I'd suggest changing the button elements to <input type="button" ...> elements
<form id="numbtns" method="post" action="imphp.php">
<input type="hidden" name="buttonID" value="1" />
<input type="button" onClick="pass(this)" value="1" />
<input type="button" onClick="pass(this)" value="2" />
<input type="button" onClick="pass(this)" value="2" />
<input type="submit" id="confirm" value="Submit" />
</form>
Javascript:
function pass(button) {
document.getElementById("buttonId").value = button.value;
}

add query on href using input

I have an
<input type=text name=search />
and I wanted to add the value of input to my href
<a href='index.php?search=$search>submit</a>
But I think that won't work on php alone right?
How can I add the value of my input to my href as it clicks?
NOTE: need to appear in the browser url menu this way
index.php?search=anyvalue
as soon as they click it. because I'm using pagination
Straight HTML - no PHP or JavaScript Needed
<form action="index.php" method="get">
<input type="text" name="search" />
<button type="submit">Submit</button>
</form>
Once clicked it will take the user to: index.php?search={value of input}
For pagination to work it would be:
Page 2
Page 3
try this:
<form method="get" action="index.php">
<input name="search" type="text" />
<input type="submit" />
</form>
If that's not what your looking for just elaborate a bit on what you are trying to achieve.
you must open a php tag like this:
<a href='index.php?search=<?php echo $search;?>' >submit</a>
but it work after submitting the form.
use javascript

Categories