| |
Welcome to Webmaster Forums 101!
You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact support.
|
 |
13th August 2003, 03:37 PM
|
#1
|
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
|
Installation script help
Hey guys i need some help creating a installation script to install the mysql tables into the database.
What i want it to do is create the tables then take the admin password,username and email address from the form i made and insert the admin username,password and email address into one of the tables and change the user level to admin.
if you need the code i have so far let me know and i'll post it.
Thanks
Viper
__________________
|
|
|
14th August 2003, 06:18 AM
|
#2
|
Join Date: Jan 2003
Posts: 374
Points: 0.00
|
I think Mr. Tech, the greatest php wiz may know
|
|
|
14th August 2003, 09:45 AM
|
#3
|
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
|
Yes I do know:
Quote:
<?php
$db_host = "localhost";
$db_name = "dbname";
$db_user = "dbusername";
$db_pass = "dbpassword";
class DB_Sql {
var $Connect = false;
var $ReValue = false;
var $ReSelect = false;
var $Host;
var $Database;
var $User;
var $Password;
var $Value;
var $numrow = false;
function DB_Sql($host,$user,$pass,$dbname) {
$this->Host = $host;
$this->User = $user;
$this->Password = $pass;
$this->Database = $dbname;
}
function DBconnect() {
if (!$this->Connect) {
$this->Connect = @mysql_connect($this->Host, $this->User, $this->Password);
$this->ReSelect = @mysql_select_db($this->Database, $this->Connect);
}
}
function query($sql) {
$this->free();
$this->DBconnect();
if ($this->ReValue = mysql_query($sql, $this->Connect)) {
$this->numrow = @mysql_num_rows($this->ReValue);
}
}
function nrecord() {
$this->Value = mysql_fetch_array($this->ReValue);
return $this->Value;
}
function datadump ($table) {
$result .= "# Dump of $table table \n";
$result .= "# Created by Customized Scripts \n";
$result .= "# Dump DATE : " . date("Y-m-d") ."\n\n";
$this->query("select * from $table");
$num_fields = @mysql_num_fields($this->ReValue);
$numrow = $this->numrow;
for ($i =0; $i<$numrow; $i++) {
//if (!mysql_data_seek ($this->ReValue, $i)) continue;
if (!($row = $this->nrecord())) continue;
$result .= "INSERT INTO ".$table." VALUES(";
for($j=0; $j<$num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) $result .= "\"$row[$j]\"" ; else $result .= "\"\"";
if ($j<($num_fields-1)) $result .= ",";
}
$result .= ");\n";
}
return $result . "\n\n\n";
}
function free() {
if ($this->ReValue) {
@mysql_free_result($this->ReValue);
$this->ReValue = false;
$this->numrow = false;
}
}
}
$db = new DB_Sql($db_host2,$db_user2,$db_pass2,$db_name2);
$db->DBconnect();
if (!$db->Connect) $errcode .= "<li>Cannot connect to the database!</li>\n";
if (!$db->ReSelect) $errcode .= "<li>Incorrct or non existing database name!</li>\n";
$dump = @file("install.sql");
$count = count($dump);
for ($i=0 ;$i<$count ;$i++) {
if (!trim($dump[$i])) continue;
if (ereg("^#",$dump[$i])) continue;
$content .= str_replace(";","",$dump[$i]);
if (ereg(";$",trim($dump[$i]))) {
$db->query($content);
$content = "";
}
}
?>
|
Replace install.sql with the .sql file you have the tables in.
Hope that helps
|
|
|
14th August 2003, 11:11 AM
|
#4
|
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
|
thanks
thanks mr.tech i'll give that a try.
__________________
|
|
|
17th August 2003, 09:14 AM
|
#5
|
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
|
php help
sorry for the double post mr.tech but i'd thought i'd keep this in the same thread instead of making a new one for it. I got my installation script working good but now i want to check the two password fields to make sure the passwords match but i don't know how to. I know how to post them in the php file but i don't know how to set up th if statement to check both password fileds to make surethey match.
Any help would be appreciated
Thanks again.
__________________
|
|
|
18th August 2003, 10:44 AM
|
#6
|
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
|
Re: php help
Quote:
|
Originally Posted by viper
sorry for the double post mr.tech but i'd thought i'd keep this in the same thread instead of making a new one for it. I got my installation script working good but now i want to check the two password fields to make sure the passwords match but i don't know how to. I know how to post them in the php file but i don't know how to set up th if statement to check both password fileds to make surethey match.
Any help would be appreciated
Thanks again.
|
This should do it:
Code:
<?php
if ($check) {
// If Passwords Match
if ($password1 == $password2) {
print "Passwords Match!!!";
// If Passwords Dont Match
} else {
print "Passwords Dont Match!!!";
}
// Fill Out Form
} else {
?>
<form action="check.php" method="post">
<input type="hidden" name="check" value="true">
Password1: <input type="text" name="password1"><br>
Password2: <input type="text" name="password2"><br>
<input type="submit" value="Check!">
</form>
<?php
}
?>

|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
| Useful Resources |
| Webmaster Resources |
| |
| Developers Tools |
| |
| Developer Tutorials |
| |
|
All times are GMT +10. The time now is 10:06 AM.
|
|