Jump to content

how to get a databse value from user


rahber

Recommended Posts

hello i am creating a databse using php .. i am using wamp server

 

here is my code

<title>Install database</title>

<?php
$server="";
$user="root;
$password="";
$database="";
$con = mysql_connect($server,$user,$password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

if (mysql_query("CREATE DATABASE z_db",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }


mysql_select_db($database, $con);

$sql = "CREATE TABLE rahber
(
FirstName varchar(20),
LastName varchar(20),
FatherName varchar(20),
PhoneNo int,
Dob date,
CGPA float

)";


mysql_query($sql,$con);

mysql_close($con);
?>

 

All i want is that  the values of $server

$user

$password

$database

should be entered from a text field when we run this file so that when each user open the file he can manual enter the values without editing the php code

Link to comment
https://forums.phpfreaks.com/topic/198629-how-to-get-a-databse-value-from-user/
Share on other sites

I'm so confused...

 

You want to let your users enter that information?

 

1. How would they know it?

2. THEY SHOULD NEVER KNOW THIS INFO!  :)

 

This information should be kept in a separate .php file with the information already entered and then called at the top of each of your pages.

 

Maybe I'm misunderstanding.

hey thanks for the reply

 

the thing is i want that when install.php runs it ask your for the database server,name,user,password... then it create that database and add tables.. then store the name ,server info into config.php file that can be used in other files also

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.