Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Request: Php Submit Script With Save In Host


14 replies to this topic

#11 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 24 May 2006 - 10:13 PM

Hi all
Iam tired because my code is not working true , i write this code for make one membership script
plz help me and debug this code
thanks

Database.sql :
CREATE TABLE news (
id tinyint(4) NOT NULL auto_increment,
username text NOT NULL,
password text NOT NULL,
email text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM; 

config.php :
<?php 
mysql_connect("localhost","root","") or die(mysql_error()); 
mysql_select_db("member") or die(mysql_error());
?> 

make.php :
<?php

if (!isset($_POST['submit'])) {

?>

<form method="POST" action="">
<p><input type="text" name="user" size="20" value="username"><br><input type="text" name="pass" size="20" value="password"><br><input type="text" name="email" size="20" value="email"></p>
<input type="submit" value="submit" name="submit">
</form>

<?php

} else {


$user = $_POST['user'];
$pass = $_POST['pass'];
$email = $_POST['email'];


include "config.php";

$result = MYSQL_QUERY("SELECT * from news WHERE username='$user'");
$worked = mysql_fetch_array($result);

if($worked){
echo "un , roor";
}else{
mysql_query("INSERT INTO news (username,password,email ) VALUES ('$user','$pass','$email')");
echo "Your name and password have been submitted into our database";
}
}
?>

login.htm :
<form method="POST" action="getin.php">
<p><input type="text" name="user" size="20" value="username"><br><input type="text" name="pass" size="20" value="password"></p>
<input type="submit" value="submit" name="submit">
</form>




* this file has error :
getin.php :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<?php
include "config.php";

$username = $_POST['user'];
$password = $_POST['pass'];

$result = MYSQL_QUERY("SELECT * from news WHERE username='$username'and password='$password'")
or die ("Name and password not found or not matched");

$worked = mysql_fetch_array($result);
$username = $worked[username];
$password = $worked[password];
$email = $worked[email];


if($worked)
echo "Welcome $user! Your e-mail address is $email";
setcookie( "user", "$user", time()+3600, "/", "", 0 );
?>
</head>
<body>
</body>
</html>


My problem is setcookie , :) when i login with username and password it show me this message :
Welcome admin! Your e-mail address is email
Warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\membership\getin.php:4) in c:\wamp\www\membership\getin.php on line 21


i know i can make cookie with setcookie(); :)
i want make one page for example test.php and if my members has login can view my test.php page
sorry my english is not very good :)
plz help me , i saw this link : http://ir.php.net/ma...n.setcookie.php but i can't debug this code
thanks all

#12 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 24 May 2006 - 11:27 PM

hi
i search with google and i find this code :
function mkcookie($cookiename,$cookievalue,$cookietime){
setcookie( "membership", "farsiscript");
echo $_COOKIE["membership"];
echo $HTTP_COOKIE_VARS["membership"];
 }
but my problem is :
i can not check cookie in test.php file , i use this code :
<?php
if (isset($_COOKIE['membership'])) {

   echo"in";

	  exit;

   } else {

echo" out";

	  exit;

   }


?>
what code i must use to check my cookie ?
thanks , i need your help

#13 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 28 May 2006 - 04:36 PM

no body loves me :)
i find this code for get html page soruce and save in sql :
<?php
$fd = fopen ("http://www.yoursite.com/index.htm", "r");
while (!feof ($fd)) {
	$buffer = fgets($fd, 4096);
	echo $buffer;
}
fclose ($fd);
?>
you can use this code to get page source , i write this code for sale template script
you can send $buffer to sql or print at page or ....
:)

#14 Yarrgh

    Newbie [Level 1]

  • Kontributors
  • Pip
  • 21 posts

Posted 29 May 2006 - 10:30 PM

The problem in the getin.php file is that you have html before you tried to send the cookie. If you do that you'll get an error. Try movie everything above the html and then placing the variables where you want them in the html.

Example:
<?php
include "config.php";

$username = $_POST['user'];
$password = $_POST['pass'];

$result = MYSQL_QUERY("SELECT * from news WHERE username='$username'and password='$password'")
or die ("Name and password not found or not matched");

$worked = mysql_fetch_array($result);
if ($worked) {
$username = $worked[username];
$password = $worked[password];
$email = $worked[email];

setcookie( "user", "$user", time()+3600, "/", "", 0 );
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<?php
if($worked) {
echo "Welcome $username! Your e-mail address is $email";
}
?>
</head>
<body>
</body>
</html>

Edited by Yarrgh, 29 May 2006 - 10:31 PM.


#15 Guest_gurpinder_*

  • Guests

Posted 12 May 2011 - 07:27 AM

savsoft test version 4.0 is a php based application which can create and manage online test .we also provide domain registration and hosting service for this application.
you can create various types of questions like true false , short answers and multiple choice questions. you can also create negative marks in the test. In multiple choice questions you can create both check-box and radio button type of question ( in check box type questions member can select multiple options as a correct answer and in radio type question user can select only single option as a answer) . You can integrate (attach) number of any files with a question . It supports image ( jpeg , gif , and png ) , video (flv , wmv , and swf) and audio files ( mp3 and wma ). Its decrypeted version you can edit and modify as your requirement
please try our free online demo available on our website (www.savsoft.co.in). If you did not find your requirements in this application then contact us for customize this application as per your requirement.




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users