Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Everything posted by DeanWhitehouse

  1. isn't a maths function, e.g greater than and less than
  2. <?php if(isset($_POST['construction'])){ $construction = $_POST['construction']; $handle = fopen('config.php', 'w+'); //open the file for writing $content = "<?php define('CONSTRUCTION', '{$construction}'); ?>"; //the content to be written fwrite($handle, $content); //write it fclose($handle); } ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method='POST'> <select name="construction"> <option value="yes">yes</option> <option value="no">no</option> </select> <input type="hidden" name="construction" value="true"><input type="submit" value="Submit"> </form>
  3. <form action="<?php $_SERVER['PHP_SELF']; ?>" method='POST'> <input type="hidden" name="construction" value="true"><input type="submit" value="Submit"> if it doesn't work add these, input type before the other input type
  4. is it the same error? or different line
  5. <?php echo'<div id="contact"> <h2>You have an error please check your message and try again!</h2> <form id="contact_form" name="contact_form" method="post" action="$_SERVER['PHP_SELF']"> <label>Name:<br /> <input name="name" type="text" class="form" id="name" /> </label> <br /><br /> <label>Email:<br /> <input name="email" type="text" class="form" id="email" /> </label> <br /><br /> Message:<br /> <label> <textarea name="message" cols="45" rows="5" class="form" id="message"></textarea> </label> <br /><br /> <label> <input name="submit" type="submit" class="form_button" id="submit" value="Submit" /> </label> </form> </div> '; } elseif (isset($email)||isset($name)||isset($message)||!empty($message)||!empty($email)||!empty($name)) { echo ' <div id="contact"> <form enctype="multipart/form-data" name="contact_form" method="post" action="$_SERVER['PHP_SELF']"> <br /><br /><Br /><br /><b> Thank You,<br /><br /> Vicious Vamp will review your message soon!<br /><br /></b> </form> </div> '; mail('viciousvamp@gmail.com','Mail for ViciousVamp',$message,$headers); } else { echo ' <div id="contact"> <form id="contact_form" name="contact_form" method="post" action="$_SERVER['PHP_SELF']"> <label>Name:<br /> <input name="name" type="text" class="form" id="name" /> </label> <br /><br /> <label>Email:<br /> <input name="email" type="text" class="form" id="email" /> </label> <br /><br /> Message:<br /> <label> <textarea name="message" cols="45" rows="5" class="form" id="message"></textarea> </label> <br /><br /> <label> <input name="submit" type="submit" class="form_button" id="submit" value="Submit" /> </label> </form> </div>'; } include ("inc/footer.inc.php"); ?>
  6. yer, delete all the <<<<html, (are the spose to be comments or <html>)?? comments in PHP are // on one line or /* */ on more than one
  7. ok, what do u want it to do? database? etc.
  8. <?php else { //missing echo '<<<HTML <div id="contact"> <form id="contact_form" name="contact_form" method="post" action="'$action'"> <label>Name:<br /> <input name="name" type="text" class="form" id="name" /> </label> <br /><br /> <label>Email:<br /> <input name="email" type="text" class="form" id="email" /> </label> <br /><br /> Message:<br /> <label> <textarea name="message" cols="45" rows="5" class="form" id="message"></textarea> </label> <br /><br /> <label> <input name="submit" type="submit" class="form_button" id="submit" value="Submit" /> </label> </form> </div> HTML'; } //missing the last else.
  9. dude are you really that stuck?? If so i will write the code, for free, but just a basic one.
  10. so do people think i should use ob_start(); or try and change the code and find a way to make it work
  11. no, not what i meant, i mean this <?php echo "$welcome"; ?> this is editable, would this be better to be saved in .inc.php file or mysql
  12. as shown in the code i tried meta refresh and header and both present with the same issue, also i can't set the cookies either. the header file needs to be changed or the something else.
  13. o ok, then so for my CMS/Website Template would you recomend storing things like welcome message etc. in the database rather than a .inc.php file?
  14. i disagree, i think it is easier to edit and access using .inc.php and databases (from what i have seen from PHP cms) are not generally used to store large pieces of data, like whole page content.
  15. no problem. i now have another problem, (acutally the reason i tried this way was to overcome the problem). i need the form to redirect after the user logged in depending on there userclass. It is meant to redirect to the page they where on, but the header information is already been sent by another file, can anyone see a way to get around this? header.php <?php session_start(); echo ("<title>$site_title</title>"); echo ("<link rel='stylesheet' type='text/css' href='../Themes/style.css' />"); echo ("<table class='title'><tr><td align='center'><h1>$custom_header</h1></td></tr></table>"); ?> this is where the header information is already sent from this is where i need to redirect if ($user_level == 1) { $login_check = @mysql_fetch_array(mysql_query("SELECT * from `$user` WHERE user_name = '$_GET[u]' AND user_password = '$_GET[p]'")); $userright = array($login_check['user_name'], $login_check['userlevel']); $s_userpass = serialize($userpass); setcookie( "$cookiename" , $s_userpass , time()+$custom_time , "" , "127.0.0.1" ); header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]); $_SESSION['is_valid'] = true; //change the session variable name to what you want, just remember it for all files $_SESSION['username'] = $row['user_name']; $_SESSION['user_level'] = $row['userlevel']; } elseif ($user_level == 2){ $login_check = @mysql_fetch_array(mysql_query("SELECT * from `$user` WHERE user_name = '$_GET[u]' AND user_password = '$_GET[p]'")); $userright = array($login_check['user_name'], $login_check['userlevel']); $s_userpass = serialize($userpass); setcookie( "$cookiename" , $s_userpass , time()+$custom_time , "" , "127.0.0.1" ); echo "<meta http-equiv='refresh' content='0; url=../index.php'>"; $_SESSION['is_valid'] = true; //change the session variable name to what you want, just remember it for all files $_SESSION['username'] = $row['user_name']; $_SESSION['user_level'] = $row['userlevel']; } }
  16. yer, but this is for storing information that you want to edit, like the page title for example. He wasn't asking where to store user data.
  17. http://www.phpfreaks.com/forums/index.php/topic,192840.msg866700.html#msg866700 read this for more info on the .inc.php file this code will write to the file( to edit it i am still unsure, as i beleive this rewrites the whole file) <?php //it makes this file, if it doesn't exist $config_file = "../includes/config.inc.php"; $fw=fopen($config_file,"w+") or die("Unable to open file!"); // Unable to open file $config_host = "\$dbhost = \"".$dbhost."\";\n"; $config_user = "\$dbuser = \"".$dbuser."\";\n"; $config_pass = "\$dbpass = \"".$dbpass."\";\n"; $config_db = "\$dbname = \"".$dbname."\";"; $config_write = $config_host.$config_user.$config_pass.$config_db; fwrite($fw, "<?php\n".$config_write."\n?>"); fclose($fw); ?>
  18. ok, thanks i changed my code like this <?php require_once '../includes/main.inc.php'; require_once '../includes/db_connect.php'; require_once '../includes/config_table.inc.php'; session_start(); // Only include the header and footers if you have to print errors function print_error($err_message) { require_once '../includes/header.php'; require_once '../includes/footer.php'; require_once '../nav_bar.php'; echo $err_message; exit; } if(isset($_POST['admin_login'])){ $user_name = $_POST["user_name"]; $user_password = $_POST["user_password"]; $verify_username = strlen($user_name); $verify_pass = strlen($user_password); if ($verify_pass > 0 && $verify_username > 0) { $salt = substr($user_password, 0, 2); $userPswd = crypt($user_password, $salt); $sql = "SELECT * FROM `$user` WHERE user_name='$user_name' AND user_password='$userPswd' LIMIT 1;"; $result = mysql_query($sql); if (mysql_num_rows($result) == 1){ $row = mysql_fetch_assoc($result); $user_level = $row['userlevel']; if ($user_level == 1) { $login_check = @mysql_fetch_array(mysql_query("SELECT * from `$user` WHERE user_name = '$_GET[u]' AND user_password = '$_GET[p]'")); $userright = array($login_check['user_name'], $login_check['userlevel']); $s_userpass = serialize($userpass); setcookie( "$cookiename" , $s_userpass , time()+$custom_time , "" , "127.0.0.1" ); header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]); $_SESSION['is_valid'] = true; //change the session variable name to what you want, just remember it for all files $_SESSION['username'] = $row['user_name']; $_SESSION['user_level'] = $row['userlevel']; } elseif ($user_level == 2){ $login_check = @mysql_fetch_array(mysql_query("SELECT * from `$user` WHERE user_name = '$_GET[u]' AND user_password = '$_GET[p]'")); $userright = array($login_check['user_name'], $login_check['userlevel']); $s_userpass = serialize($userpass); setcookie( "$cookiename" , $s_userpass , time()+$custom_time , "" , "127.0.0.1" ); echo "<meta http-equiv='refresh' content='0; url=../index.php'>"; $_SESSION['is_valid'] = true; //change the session variable name to what you want, just remember it for all files $_SESSION['username'] = $row['user_name']; $_SESSION['user_level'] = $row['userlevel']; } } else{ print_error( 'Login failed. Username and Password did not match database entries.'); } } else { print_error( "Form was not completed. Please go back and make sure that the form was fully completed."); } mysql_close(); ?> <html> <table bgcolor='#999999' align='right'><form action="<?php $_SERVER['PHP_SELF']; ?>" method='POST'> <tr><td>Username: </td><td><input type='text' name='user_name' /><br /></td></tr> <tr><td>Password:</td><td> <input type='password' name='user_password' /><br /></td></tr> <tr><td><input type='submit' value='Continue' name='admin_login' /></td></tr> </form></table> </html> but i get an error saying Parse error: syntax error, unexpected $end in /home/www/deanwhitehouse.awardspace.co.uk/admin/admin_login.php on line 78 this is the bottom line.
  19. erm, a better example. page 1 code <?php require_once 'edited.inc.php'; echo"$user_edited"; ?> edited.inc.php <?php $user_edited = "Stuff for users to edit"; ?> then you have a script, (which i have if you need) that will write this data into the edited.inc.php the data there can be taken from a form. Bit like mysql, without the database.
  20. Is it possible to have a login(input) form and the login(proccessor) in the same file?? And if so, can i been shown an example and how to post the form to self
  21. i am using a .inc.php file for editable content and writing to it when it is changed e.g. i have a form that submits the data. $data then i have a code that writes this data to the .inc.php file then i include the file on everypage then refer to the content by echo "$data";(or something similar) then make a form for them to edit it.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.