Help - Search - Members - Calendar
Full Version: Using Database Info in a Form
HTMLHelp Forums > Programming > Server-side Scripting
stub
The "domain" was already being displayed in the form. I'm trying to extract the "price" from the database and display that also in the form. I'm not an expert with CSS. So don't laugh if the syntax is wrong.

CODE
<div class="3u"><input type="text" name ="domain" placeholder="Domain" value="<?php echo preg_replace('/[^a-zA-Z0-9.-]/', '', $_GET['domain']); ?>"/></div>
<div class="3u"><input type="text" name ="price" placeholder="Price" value="<?php echo preg_replace('/[^a-zA-Z0-9.-]/', '', $_GET['price']); ?>"/></div>
Christian J
This is about PHP, not CSS, so I moved the thread.
Christian J
$_GET just extracts the URL's querystring. Does the latter contain a "price" value?

Furthermore, to acess the database you need the PHP script to perform a database query (which is not the same as a URL querystring).
stub
Yes there is a price value for the domain in the database. What would the database query string look like? Where should it appear? Immediately before the lookup?
stub
OK. I guess the URL query string is coming from the fact that the domain name is being sent the domain name to the form by the link the visitor has used to get to the form. So no need for a database lookup. Yes/No?

So I'm guessing I need to lookup the price of that domain in the MySQL database, and put it in the price box. How to do that?
Christian J
QUOTE(stub @ May 5 2016, 01:47 AM) *

OK. I guess the URL query string is coming from the fact that the domain name is being sent the domain name to the form by the link the visitor has used to get to the form. So no need for a database lookup. Yes/No?

Not sure I understood the above, but an ordinary link can contain a querystring. How that link is created is the problem.

QUOTE
So I'm guessing I need to lookup the price of that domain in the MySQL database, and put it in the price box.

Yes.

QUOTE
How to do that?

Does your existing PHP script contain any MySQL queries, e.g. for the "domain" INPUT field?






stub
The problem is I don't know what I'm looking for. Could you please give an example of what it might look like?
Christian J
Here are a few examples: http://php.net/manual/en/mysqlinfo.api.choosing.php

But if you have no experience with this, you really should start learning the basics first. If you try to hack existing code, maybe you'll accidentally break the database, or open it up for exploits.
stub
Thank you. I don't have anything like that in my page sad.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2019 Invision Power Services, Inc.