Webmaster Forums 101 - Free Help and Discussions
 
 
 

MEMBER REWARDS - Earn free advertising by participating in these forums! Click here for details.

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.

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th August 2003, 03:37 PM   #1
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default 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
__________________
viper is offline   Reply With Quote
Old 14th August 2003, 06:18 AM   #2

Username: metguitarist
Rank: WF101 Addict
Join Date: Jan 2003
Posts: 374
Points: 0.00
Send a message via AIM to metguitarist Send a message via MSN to metguitarist
Default

I think Mr. Tech, the greatest php wiz may know
metguitarist is offline   Reply With Quote
Old 14th August 2003, 09:45 AM   #3
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

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
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 14th August 2003, 11:11 AM   #4
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default thanks

thanks mr.tech i'll give that a try.
__________________
viper is offline   Reply With Quote
Old 17th August 2003, 09:14 AM   #5
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default 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.
__________________
viper is offline   Reply With Quote
Old 18th August 2003, 10:44 AM   #6
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default 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 } ?>

__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help creating a members only script Rainbow Server-Side Scripting & Databases 8 29th March 2005 09:02 PM
Redirect script for IE5/Mac techitout Website Design & Coding 9 12th March 2005 09:45 AM
Full Page Force Script Abraxas Server-Side Scripting & Databases 1 20th November 2003 03:15 PM
Script Ideas Mr. Tech Server-Side Scripting & Databases 4 11th June 2003 02:20 PM
nice new script!! dingclancy Suggestions and Feedback 8 31st March 2003 02:08 PM

Login
User Name
Password


Featured Members


Featured Links


Useful Resources
Webmaster Resources
Developers Tools
Developer Tutorials


Partners

All times are GMT +10. The time now is 10:06 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.3.2
 
 
WEBMASTER FORUMS 101
ARCHIVE
CONTACT US
TOP
   
© Webmaster Forums 101 2005. All Rights Reserved.
Design by: vBCore