<?php
$output ="";
if(isset($_SESSION['webValidated']) && isset($_SESSION['webShortname'])){
echo " welcome back!" .$output = print_r($_SESSION['webShortname']);
}
else{
echo " show this";
}
?>rossco welcome back!1
print_r() displays information about a variable in a way that’s readable by humans. If given a string, integer or float, the value itself will be printed. If given an array, values will be presented in a format that shows keys and elements
<?php
$mydb= new DBAPI();
$mydb->connect($host='localhost',$dbase='test', $uid='test',$pwd='test');
$output = '';
$result = $mydb->db->query( 'SELECT id, username, joined FROM `users` GROUP BY `id` ORDER BY id ASC' );
while( $row = $mydb->db->getRow( $result ) ) {
$output .= '<br /> ID: ' . $row['id'] . '<br /> Name: ' . $row['username'] . '<br /> Joined: ' . $row['joined']
. '<br />---------<br />';
}
echo $output;
?>Fatal error: Call to a member function query() on a non-object in /home/xxx/public_html/manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 4
<?php
$conn = mysql_connect("localhost", "mydb", "pass")
or die("no connection" .mysql_error());
$db = mysql_select_db("phpwork")
or die("connected" .mysql_error());
?>
<?php
$output ="";
echo "
<html>
<head>
<title>Form to DB</title>
</head>
<body>
<?php
$id = $_POST['id'];
$username = $_POST['username'];
$password = $_POST['password'];
$query = "INSERT INTO table (id, username, password) VALUES ('$id', '$username', '$password')";
?>
<p>
<form action=\"<?php $PHP_SELF ?>\" method=\"post\">
Username: <input type=\"text\" name=\"username\"
value=\"\"><br>
Password: <input type=\"password\" name=\"password\"
value=\"\"><br>
id: <input type=\"text\" name=\"id\"
value=\"\"><br>
<input type=\"submit\" name=\"submit\" value=\"Register\">
<input type=\"reset\" value=\"Clear\">
</form>
</p>
</body>
</html>
";
?><?php define(WORK_PATH, "assets/snippets/phpwork/"); $output = ""; include($modx->config['base_path'].WORK_PATH.'register.php'); return $output; ?>
<?php
$output ="";
$output .="
<html>
<head>
<title>Form to DB</title>
</head>
<body>";
// check if $_POST['id'] is set, if so do the db stuff
if(isset($_POST['id'])){
$conn = mysql_connect("localhost", "mydb", "pass")
or die("no connection" .mysql_error());
$db = mysql_select_db("phpwork")
or die("connected" .mysql_error());
$id = $_POST['id'];
$username = $_POST['username'];
$password = $_POST['password'];
$query = "INSERT INTO table (id, username, password) VALUES ('$id', '$username', '$password')";
if($query){
$output .="<p>Congratulations ".$username.", the form was filled out</p>";
}else{
$output .="<p>An error occured while saving the information</p>";
}
}else{
// show the form
$output .="<p>
<form action=\"$PHP_SELF\" method=\"post\">
Username: <input type=\"text\" name=\"username\"
value=\"\"><br>
Password: <input type=\"password\" name=\"password\"
value=\"\"><br>
id: <input type=\"text\" name=\"id\"
value=\"\"><br>
<input type=\"submit\" name=\"submit\" value=\"Register\">
<input type=\"reset\" value=\"Clear\">
</form>
</p>";
}
$output .="</body>
</html>
";
echo $output;
?><?php define(WORK_PATH, "assets/snippets/phpwork/"); include($modx->config['base_path'].WORK_PATH.'register.php'); ?>