Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2013
    Location
    Finland/Estonia
    Posts
    53
    Thanks
    9
    Thanked 0 Times in 0 Posts

    I am In a process of creating a custom blog, but I need some help

    Hello.
    I am In a process of creating a custom blog, but I need some help.
    I am a complete starter on the PHP side.
    What I need to do is to store following info into my database:


    Also, I need some info on how can I create a PHP Submission form for all of this.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    These are all easy google-able questions... "tutorial php mysql" will net you a ton of results, just don't use W3Schools.

  • Users who have thanked Keleth for this post:

    estXcrew (08-24-2013)

  • #3
    New Coder
    Join Date
    Jul 2013
    Location
    Finland/Estonia
    Posts
    53
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Just curious, what is wrong with W3Schools?

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,225
    Thanks
    23
    Thanked 606 Times in 605 Posts
    @estXcrew, There is nothing(almost) wrong with W3Schools. Some people on this forum just have a bug up their butt for them. I use them as the first place to go to get information and they have never failed me. I do check sometimes with Mozilla Developer Network here https://developer.mozilla.org/en-US/
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #5
    New Coder
    Join Date
    Jul 2013
    Location
    Finland/Estonia
    Posts
    53
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Hey sunfighter, thanks.

    I have now created something that I think should almost work. But It doesn't quite work.
    PHP Part of it
    PHP Code:
    <?php
    session_start
    ();
    if(!isset(
    $_SESSION['user_id'])){
        
    header('Location: login.php');
        exit();
    }
    include(
    '../includes/db_connect.php');
    //if submit is clicked
    if(isset($_POST['newPost'])){
        
    $newPost $_POST['newPost'];
        if(!empty(
    $newCategory)){
            
    $sql "INSERT INTO posts (body) VALUES('$newPost')";
            
    $query $db->query($sql);
            if(
    $query){
                echo 
    "New Post created";
            }else{
                echo 
    "Error";
            }
            
        }else{
            echo 
    'Missing Body text';
        }
    }
    ?>
    THe submission form
    Code:
     <div id="newPostForm">
                	<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
    					<textarea name="newPost" cols="100" rows="25"/></textarea><br>
    					<label for="post">Add New Post</label><input type="submit" name="newPost" value="Submit"/>
    
    		</div>
    When I enter something in the body it displays "Missing body text" error that I set up myself. I am sure I've misunderstood some part of it.

  • #6
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,225
    Thanks
    23
    Thanked 606 Times in 605 Posts
    You never define $newCategory

    PHP Code:
    if(!empty($newCategory)){ 
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • Users who have thanked sunfighter for this post:

    estXcrew (08-24-2013)

  • #7
    New Coder
    Join Date
    Jul 2013
    Location
    Finland/Estonia
    Posts
    53
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Codingforums is awesome. Thank you so much!


  •  

    Posting Permissions

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