Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/configuration/MysqlConfiguration.php
<?php

if(isset($msg)){ unset($msg);}

if(isset($_SESSION['locID'])){
	$loc = $_SESSION['locID'];
	}else{
		$msg= "<p class=\"error\">Please Select a Location</p>";
	if(!isset($include)) { $include = "include/location/ShowLoc.php";}
	}
$LocName = $_SESSION['LocName'];
if(!isset($buttonID)) {
	$msg= "$msg <p class=\"error\">No button ID was sent</p>"; // this shouldn't happen
}

if(!isset($msg)){
if ($buttonID=="saveconfigm") {
  $myFile = "phpmyprepaid.conf.php";
  $fh = fopen($myFile, 'w');
  $stringData='<?php'."\n";
  fwrite($fh, $stringData);
 
  //GENERAL
  $conf_pra['host']=$_POST['Server'];
  $conf_pra['user']=$_POST['User'];
  $conf_pra['password']=$_POST['Pass'];
  $conf_pra['db']=$_POST['Base'];
  $stringData = '$conf_pra[\'host\']="'.$conf_pra['host'].'";'."\n";
  fwrite($fh, $stringData);
  $stringData = 'conf_pra[\'user\']="'.$conf_pra['user'].'";'."\n";
  fwrite($fh, $stringData);
  $stringData = '$conf_pra[\'password\']="'.$conf_pra['password'].'";'."\n";
  fwrite($fh, $stringData);
  $stringData = '$conf_pra[\'db\']="'.$conf_pra['db'].'";'."\n";
  fwrite($fh, $stringData);
  $stringData = '$conf_pra[\'dbtype\']="'.$conf_pra['dbtype'].'";'."\n";
  fwrite($fh, $stringData);
  $stringData = '$conf_pra[\'sqlport\']="'.$conf_pra['sqlport'].'";'."\n";
  fwrite($fh, $stringData);
  //END
  $stringData='$connect=mysql_connect($conf_pra[\'host\'], conf_pra[\'user\'], $conf_pra[\'password\']);'."\n";
  fwrite($fh, $stringData);
  $stringData='$db=mysql_select_db($conf_pra[\'db\']);'."\n";
  fwrite($fh, $stringData);
  $stringData='if ($db=!1 or $connect==NULL) $buttonID="badconfigmysql";'."\n";
  fwrite($fh, $stringData);
  $stringData='?>';
  fwrite($fh, $stringData);
  fclose($fh);
}
echo "
<form action=\"include/configuration/SaveMysqlConfiguration.php\" method=\"post\">
<hr>
<big><big  style=\"font-family: Aircut\"><span style=\"font-weight: bold;\"><b>Mysql general configuration</span></b></big></big><br>
<hr>
<table>
<tr>
<td>Server : </td>
<td>";
echo '<input name="Server" value="'.$conf_pra['host'];
echo "\"></td>
</tr><tr>
<td>User name : </td>
<td><input name=\"User\" value=\"".$conf_pra['user']."\"></td>
</tr><tr>
<td>Password : </td>
<td><input name=\"Pass\" value=\"".$conf_pra['password']."\" type=\"password\"></td>
</tr><tr>
<td>Database name : </td>
<td><input name=\"Base\" value=\"".$conf_pra['db']."\"></td>
</tr><tr>
<td>Database type : </td>
<td><input name=\"Type\" value=\"".$conf_pra['dbtype']."\"></td>
</tr><tr>
<td>Database port : </td>
<td><input name=\"Port\" value=\"".$conf_pra['sqlport']."\"></td>

<br>
</tr>
</table>
<hr>
<input type=\"hidden\" name=\"buttonID\" value=\"saveconfigm\">
<input name=\"submit\" class=\"smallButton\" type=\"submit\" value=\"Save Configuration\" >
</form>
";
}
else echo $msg;
Return current item: phpMyPrepaid