Jump to content

Imothep

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Imothep's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I want all my scripts on index.php. So when i press submit for login. It takes the script from index.php. that can be done using <form action="index.php" But when i put my scripts on the index.php script.. they start outputting, and i dont want them to do that before i have called them.
  2. Lets say i have the index.php site. And i want it to do different things. Lets use "login" as an example. when i call the login script. I want it to take the script from the index.php page. Not call a script outside index.php. so i dont have to make many different pages. This is an example of the html code i have for my login form on "index.php" as you can see it calls an internal page with the login script in it. But if i try to do what i want to do.. changing <form action="index.php" <--- to this. it starts to output the echo statements i made in the login scripts. There must be some way of stopping the scripts to output before you have called it.? [code]<form id="form1" name="form1" method="post" action="login.php">                 <label>Email:<br />                   <input name="email" type="text" class="login" id="email" />                   </label>                   <p>                     <label>Password:                       <input name="password" type="password"  class="login" />                       </label>                     </p>                     <p><input type="submit" class="login" value="Login" /></p>               </form>[/code]
  3. Hello guys.. i want to run multiple scripts on the index page for different forms on the page example: login & registration. But when i use the scripts on the website they start outputting. How can i prevent this ? I want them to do something if the submit button for the forms have been pressed. Thank you .. i know im not very good at explaining. :(
  4. Hello im using phpmyadmin to configure my tables. And i have a textarea that is supposed to submit information to the mysql table  [code]<textarea name="description" rows="10" cols="30">[/code] and my row name is "description" and i have tried using TEXT TYPE, BLOB TYPE etc it doesnt work :S Anyone have any idea ?
  5. Ok thank you King Arthur.. can you show me an example of how to do that using my script ? I would be very greatfull.. Thanks again
  6. Warning: Wrong parameter count for session_destroy() in /home/1/p/pixelpeople/www/larf/logout.php on line 1 Warning: Cannot modify header information - headers already sent by (output started at /home/1/p/pixelpeople/www/larf/logout.php:1) in /home/1/p/pixelpeople/www/larf/logout.php on line 2 Successfully logged out that is the error i get
  7. i tried adding session_destroy to my code [code]<? session_destroy("username"); header("location:http://www.pixelpeople.org/larf/"); echo "Successfully logged out"; die;?>[/code] but it still doesnt work :S
  8. [quote author=Imothep link=topic=101785.msg403116#msg403116 date=1153829775] Hello folks im a PHP noob and im having trouble with sessions. [code]<?php session_start(); $host="xxxxxx"; $username="xxxxxx"; $password="xxxxx"; $database="XXXXX"; $larfuser=$_POST['email']; $larfpass=$_POST['password']; mysql_connect($host, $username, $password) or die("Could not connect to the server"); mysql_select_db($database) or die("Could not connect to the database"); $sql=mysql_query("SELECT * FROM larf_users WHERE email='$larfuser' AND password='$larfpass'"); if (mysql_num_rows($sql)==0) { echo"Could not log you in."; exit; }else{ session_register("username"); $_SESSION['welcome'] = "Welcome to your control panel $larfuser"; header("location:http://www.pixelpeople.org/larf/usernames.php"); } ?>[/code] This site does what it is supposed to.. it takes me to the usernames.php if the usrname and pw corresponds to the information in the mysql db. However, when i try to logout on the usernames page and i try to press back in the browser i can still access usernames.php. How can i prevent that ? This is my code for logout.php [code]<? session_unset("username"); header("location:http://www.pixelpeople.org/larf/"); echo "Successfully logged out"; die;?>[/code] Please do not laugh.. i started doing PHP 2 weeks ago and im enjoying it :) Can anyone give me a noobfriendly explanation to what is wrong here and how i can correct it? Tips and Tricks are most welcome... hehe Thank you very much folks! [/quote]
  9. Hello folks im a PHP noob and im having trouble with sessions. [code]<?php session_start(); $host="xxxxxx"; $username="xxxxxx"; $password="xxxxx"; $database="XXXXX"; $larfuser=$_POST['email']; $larfpass=$_POST['password']; mysql_connect($host, $username, $password) or die("Could not connect to the server"); mysql_select_db($database) or die("Could not connect to the database"); $sql=mysql_query("SELECT * FROM larf_users WHERE email='$larfuser' AND password='$larfpass'"); if (mysql_num_rows($sql)==0) { echo"Could not log you in."; exit; }else{ session_register("username"); $_SESSION['welcome'] = "Welcome to your control panel $larfuser"; header("location:http://www.pixelpeople.org/larf/usernames.php"); } ?>[/code] This site does what it is supposed to.. it takes me to the usernames.php if the usrname and pw corresponds to the information in the mysql db. However, when i try to logout on the usernames page and i try to press back in the browser i can still access usernames.php. This is my code for logout.php [code]<? session_unset("username"); header("location:http://www.pixelpeople.org/larf/"); echo "Successfully logged out"; die;?>[/code] Please do not laugh.. i started doing PHP 2 weeks ago and im enjoying it :) Can anyone give me a noobfriendly explanation to what is wrong here and how i can correct it? Tips and Tricks are most welcome... hehe Thank you very much folks!
  10. Hello folks, i know now how to make a news script for posting news and displaying them using mysql, But i dont know how to make that news into a link so that people can see the whole news. example: use the topic as a link then press the link so the news shows up. I have an idea that the ID columms in the database have something to do with this. Does anyone have a link to a tutorial or an example of this? Thank you very much Fredrik Christensen Ip Generation Ltd
  11. Also mate.. is there a lot of work to do a USER EXISTENCE check? so that users cant register twice ?
  12. I found the problem Ken.. I forgot to use INT AUTO_INCREMENT on the userid field. IM sorry to bother you about this, but stupid errors occur all the time for me :P lol Thanks alot!
  13. Problem with the query: INSERT INTO `larf_users` (`firstname`, `surname`, `email`, `landphone`, `mobilephone`, `postalcode`) VALUES ( 'Fredrik', 'Christensen', 'fredrik@pixelpeople.org', '22222222', '', 'SW19 5DH') Duplicate entry '' for key 1
  14. :( Thank you very much but it doesnt seem to be entering data into the database: This is my whole script... please dont laugh  :P im a n00b. But the mail functions and the echo functions work perfectly :S except from the mysql_query :S [code]<?php $username="xxxxxx"; ( changed for security reasons) $password="xxxxxx"; ( changed for security reasons) $server="xxxxxx"; ( changed for security reasons) $database="xxxxxx"; ( changed for security reasons) $adminmail="fred@ipgeneration.co.uk"; $required="This is a required field *"; $usermail= $_POST['email']; $adminmessage= " \n" . "\n" . "\n" . "Name: $_POST[firstname] $_POST[surname]"  . "\n" . "\n" . "\n" . "User email: $_POST[email]"  . "\n" . "\n" . "\n" . "Landline phone: $_POST[landphone]" . "\n" . "\n" . "\n" . "Mobile phone: $_POST[mobilephone]" . "\n" . "\n" . "\n" . "Postal Code : $_POST[postalcode]" . "\n" . "\n" . "\n"; mysql_connect($server, $username, $password) or die(" could not connect to the server please contact $adminmail for more information"); mysql_select_db($database) or die("Could not connect to the database"); if(empty($_POST['firstname'])) { echo "You did not fill in your Firstname $required"; } echo "<br>"; if(empty($_POST['surname'])) { echo "You did not fill in your Surname $required"; } echo "<br>"; if(empty($_POST['email'])) { echo "You did not fill in your email $required"; } echo "<br>"; if(empty($_POST['landphone'])) { echo "You did not fill in your land phone number $required"; } echo"<br>"; if(empty($_POST['mobilephone'])) { echo "You did not fill in your Mobile phone number $required"; } echo "<br>"; if(empty($_POST['postalcode'])) { echo "<h4>" ."You did not fill in your Postal code $required" . "</h4>"; } if (empty($_POST['firstname']) || empty($_POST['surname']) || empty($_POST['email']) || empty($_POST['landphone']) || empty($_POST['mobilephone']) || empty($_POST['postalcode'])) { } else { $sql = "INSERT INTO `larf_users` (`firstname`, `surname`, `email`, `landphone`, `mobilephone`, `postalcode`)         VALUES (         '{$_POST[firstname]}',         '{$_POST[surname]}',         '{$_POST[email]}',         '{$_POST[landphone]}',         '{$_POST[mobilphone]}',         '{$_POST[postalcode]}')"; mysql_query($sql); mail($adminmail, "New Registered user", "$adminmessage"); echo "Registration Successfull. You will shortly receive a confirmation mail with your registered details" . "<a href='index.php'> Back to Main Page? </a>"; mail($usermail, "Thank you for registerting at LARF TV", "Welcome to LARF TV $_POST[firstname] $_POST[surname]. Below you will find all the information you used to register with. If any of this information is wrong please let us know so that we can correct this manually." . "\n" . "\n" .  "Thank you and once again Welcome!" . "\n" . "\n" . "\n" . "Name: $_POST[firstname] $_POST[surname]" . "\n" . "\n" . "\n" . "User email: $_POST[email]" . "\n" . "\n" . "\n" . "Landline phone: $_POST[landphone]" . "\n" . "\n" . "\n" . "Mobile phone: $_POST[mobilephone]" . "\n" . "\n" . "\n" . "Postal Code : $_POST[postalcode]" ); } ?>[/code] anyone have any idea ? Thank you again! (edited by a moderator to put in the [nobbc][code][/code][/nobbc] tags)
  15. Hello guys.. im kinda n00bish when it comes to PHP so i hope you can help me. Basically what im trying to do is to tell mysql to insert information into the database which the user inputs through a HTML form. I tried coding this but it is not entered into the database. Also i tried to echo the mysql_query string, but nothing seems to be inserted into the variable $sql. Any help would be greatly appriciated. [b]CODE1[/b] $sql=mysql_query("INSERT INTO `larf_users` (`firstname`, `surname`, `email`, `landphone`, `mobilephone`, `postalcode`) VALUES ('$_POST[firstname]' , '$_POST[surname]', '$_POST[email]', '$_POST[landphone] ', '$_POST[mobilphone] ', '$_POST[postalcode]')" ); [b]CODE2[/b] mysql_query("INSERT INTO `larf_users` (`firstname`, `surname`, `email`, `landphone`, `mobilephone`, `postalcode`) VALUES ('" .$_POST['firstname']."', '".$_POST['surname']."', '" .$_POST['email']."', '" .$_POST['landphone']. "', '" .$_POST['mobilephone']."', '" .$_POST['postalcode']."')"); It is probably just a shabby code error somewhere.. Also can you try and give me some advice on how to make my code cleaner ? Thank you very much Fredrik Christensen Ip Generation Ltd
×
×
  • 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.