Using Database Info in a Form |
Using Database Info in a Form |
stub |
May 3 2016, 07:13 AM
Post
#1
|
Member Group: Members Posts: 36 Joined: 15-November 12 Member No.: 18,105 |
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> This post has been edited by stub: May 3 2016, 07:24 AM |
Christian J |
May 3 2016, 07:25 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
This is about PHP, not CSS, so I moved the thread.
|
Christian J |
May 3 2016, 07:30 AM
Post
#3
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
$_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 |
May 3 2016, 04:44 PM
Post
#4
|
Member Group: Members Posts: 36 Joined: 15-November 12 Member No.: 18,105 |
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?
This post has been edited by stub: May 3 2016, 04:55 PM |
stub |
May 4 2016, 06:47 PM
Post
#5
|
Member Group: Members Posts: 36 Joined: 15-November 12 Member No.: 18,105 |
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? This post has been edited by stub: May 4 2016, 06:48 PM |
Christian J |
May 4 2016, 07:57 PM
Post
#6
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
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 |
May 5 2016, 10:41 PM
Post
#7
|
Member Group: Members Posts: 36 Joined: 15-November 12 Member No.: 18,105 |
The problem is I don't know what I'm looking for. Could you please give an example of what it might look like?
This post has been edited by stub: May 5 2016, 10:46 PM |
Christian J |
May 6 2016, 07:02 AM
Post
#8
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
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 |
May 8 2016, 07:00 AM
Post
#9
|
Member Group: Members Posts: 36 Joined: 15-November 12 Member No.: 18,105 |
Thank you. I don't have anything like that in my page
|
Lo-Fi Version | Time is now: 24th April 2024 - 08:04 PM |