Results 1 to 7 of 7
Thread: PHP -
Hybrid View
-
4th December 2012 17:43 #1
PHP -
literature.php.
K , comments.php .
,
literature.php
Code:<div id="comment_box"> <form method="post" action="comments.php?id=2" name="commentform"> <label>Enter comment</label> <?php if(isset($text) || isset($name)){ if(empty($text)) echo '<p>You must enter a comment</p>'; if(empty($name)) echo '</p>You must enter a name</p>'; } ?> <textarea name="text" cols="25" rows="5"></textarea> <div id="guest"> <?php if(empty($_SESSION['username'])){ ?> <label for="name">Your name:</label> <input type="text" name="name" id="name" /> <?php } ?> </div> <br /> <input type="submit" name="post_comment" value="Post comment" /> </form> </div>
comments.php
$text,$name literature.php ?PHP Code:<?php
session_start();
require_once('login/dbConfig.php');
$id = $_GET['id'];
$text = $_POST['text'];
if((!empty($_SESSION['username']) && (!empty($text))) || (!empty($_SESSION['username']))){
$name = $_SESSION['username'];
$type = 'registered user';
}else{
$name = $_POST['name'];
$type = 'guest visitor';
}
if(!empty($name) && !empty($text)){
$query = mysql_query("INSERT INTO comments (story_id,username,user_type,date,comment) VALUES('$id','$name','$type',NOW(),'$text')");
}
mysql_close($connect);
header('Location:literature_4.php');
?>
-
5th December 2012 12:36 #2
PHP JavaScript PHP .
JavaScripta - Submit Button, OnClick , - Submit, - "submit"- literature.php?text=$text&name=$name
, " " :
literature.php?text=$text&name=$name
literature.phpASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1
-
5th December 2012 13:12 #3
, - onsubmit ( ).
<form method="post" action="comments.php?id=2" name="commentform" onsubmit="return this.elements.name.value!=''">
, .. PHP . JS .
, , hateras, , "" , .. URL- . ID, ( ). -, ( ) , . , PHP ..
. .. " ", . , , , -, ..
-
5th December 2012 13:22 #4
, tedych, , 1-2 ,
- .
ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1
-
5th December 2012 15:03 #5
, comments.php literature.php , - .
-
5th December 2012 18:08 #6Registered User
Join Date: Nov:2008
Location: Sofia
Posts: 97
"" - (onchange, keypress , ). PHP .




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in