Results 1 to 7 of 7

Thread: PHP -

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User zombie13's Avatar
    Join Date: Oct:2012
    Location: Bulgaria - Ruse
    Posts: 63

    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
    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');
    ?>
    $text,$name literature.php ?

  2. #2
    Registered User hateras's Avatar
    Join Date: Jan:2011
    Location: Kronos III
    Posts: 1,028
    PHP JavaScript PHP .
    JavaScripta - Submit Button, OnClick , - Submit, - "submit"- literature.php?text=$text&name=$name
    , " " :
    literature.php?text=$text&name=$name
    literature.php
    ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1

  3. #3
    Registered User tedych's Avatar
    Join Date: Nov:2003
    Location:
    Posts: 17,654
    , - onsubmit ( ).
    <form method="post" action="comments.php?id=2" name="commentform" onsubmit="return this.elements.name.value!=''">
    , .. PHP . JS .

    , , hateras, , "" , .. URL- . ID, ( ). -, ( ) , . , PHP .. . .. " ", . , , , -, ..

  4. #4
    Registered User hateras's Avatar
    Join Date: Jan:2011
    Location: Kronos III
    Posts: 1,028
    , 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

  5. #5
    Registered User zombie13's Avatar
    Join Date: Oct:2012
    Location: Bulgaria - Ruse
    Posts: 63
    , comments.php literature.php , - .


  6. #6
    Registered User
    Join Date: Nov:2008
    Location: Sofia
    Posts: 97
    "" - (onchange, keypress , ). PHP .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |