Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-08-2009, 10:50 AM Php Install script.
Super Talker

Posts: 115
Name: Not Telling
Trades: 0
Basicly what I am doing is making a php install script.


I currently have this (It connects to the database):

Code:
<?php
// Make a MySQL Connection
mysql_connect("localhost", "db_u", "db_p") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
 
// Create a MySQL table in the selected database
mysql_query("
CREATE TABLE IF NOT EXISTS `Persons` (
  `FirstName` varchar(15) NOT NULL,
  `LastName` varchar(15) NOT NULL,
  `Ip` varchar(50) NOT NULL,
  `AddedDate` varchar(50) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
")or die(mysql_error()); 

// Create a MySQL table in the selected database
mysql_query("
CREATE TABLE IF NOT EXISTS `Advert` (
  `id` int(255) NOT NULL auto_increment,
  `code` longtext NOT NULL,
  `code1` longtext NOT NULL,
  `code2` longtext NOT NULL,
  `code3` longtext NOT NULL,
  `code4` longtext NOT NULL,
  `code5` longtext NOT NULL,
  `code6` longtext NOT NULL,
  `code7` longtext NOT NULL,
  `code8` longtext NOT NULL,
  `code9` longtext NOT NULL,
  `code10` longtext NOT NULL,
  `code11` longtext NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
")or die(mysql_error()); 

 
echo "Table Created!";
 
?>
See the stuff in red? I want a form to fill out those options. Like this is what I mean.

Code:
<form name="input" action="install2.php" method="get">
Username:
Website Server: <input type="text" name="localhost" /><br>
Database: <input type="text" name="db" /><br>
Database User: <input type="text" name=db_u" /><br>
Database Password: <input type="text" name="db_p" /><br>
<input type="submit" value="Submit" />
</form>
Can someone help me out?
sith717 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-08-2009, 04:22 PM Re: Php Install script.
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
You can try something along these lines:

PHP Code:
<?php
// Make a MySQL Connection
$localhost preg_replace('/[^0-9a-z\.\-_]/i','',$_POST['localhost']);
$db_u preg_replace('/[^0-9a-z\.\-_]/i','',$_POST['db_u']);
$db_p preg_replace('/[^0-9a-z\.\-_]/i','',$_POST['db_p']);
$db preg_replace('/[^0-9a-z\.\-_]/i','',$_POST['db']);
if (!empty(
$localhost) && !empty($db_u)  && !empty($db_p)  && !empty($db) ) {
  
mysql_connect($localhost$db_u$db_p) or die(mysql_error());
  
mysql_select_db($db) or die(mysql_error());
  
  
//The rest of your code here
  
  
} else {
  
//The user did not fill in all values, so show an error message.
}
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Php Install script.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10561 seconds with 12 queries