Results 1 to 3 of 3

Thread: php isset simplify

  1. #1
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,530
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default php isset simplify

    Hello everyone.

    I'm trying to make it so that if the session is already set, it looks the div windows and all that. If the session isn't set but the form has been sent, it saves the info sent to the session then displays the div windows and all that. If the session isn't set or the form, it comes up with a form to fill in your name. It's so complicated that I can't get it to work. Could one of you guys help me out?

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by keyboard1333 View Post
    Hello everyone.

    I'm trying to make it so that if the session is already set, it looks the div windows and all that. If the session isn't set but the form has been sent, it saves the info sent to the session then displays the div windows and all that. If the session isn't set or the form, it comes up with a form to fill in your name. It's so complicated that I can't get it to work. Could one of you guys help me out?
    Your question is unclear.
    Please provide more information, and be as specific as possible.
    • What do you want to accomplish?
    • What have you already tried?
    • What problems did you encounter?

    Also, please be sure that you have included all relevant code and/or a link to the page in question.


    I really can't follow what you're trying to describe there. Can you explain a little? Particularly some background information about what you're doing - what do you mean by "looks the div windows," and so forth.

  3. #3
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,530
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    Oops, sorry forgot to post my code

    Code:
    <?php
    session_start();  
    require "settings.php";
    if(!isset($_SESSION['uniqueid'])) {
    ?>
    <html>
    <head>
    <style type="text/css">
    #fldrChatWindow {
    width:<?php echo $fldr_CW_width; ?>;
    height:<?php echo $fldr_CW_height; ?>; 
    background-color:<?php echo $fldr_CW_bgcolor; ?>;  
    border-top:<?php echo $fldr_CW_border_top; ?>;
    border-right:<?php echo $fldr_CW_border_right; ?>;
    border-left:<?php echo $fldr_CW_border_left; ?>;
    border-bottom:<?php echo $fldr_CW_border_bottom; ?>;
    overflow:auto;
    word-wrap:break-word;
    }
    #fldrChatWindowInput {
    width:<?php echo $fldr_CWI_width; ?>;
    height:<?php echo $fldr_CWI_height; ?>; 
    background-color:<?php echo $fldr_CWI_bgcolor; ?>;
    border-top:<?php echo $fldr_CWI_border_top; ?>;
    border-right:<?php echo $fldr_CWI_border_right; ?>;
    border-left:<?php echo $fldr_CWI_border_left; ?>;
    border-bottom:<?php echo $fldr_CWI_border_bottom; ?>;
    overflow:auto;
    word-wrap:break-word;
    }
    #fldrChatWindow p {
    margin: 0;
    }
    #fldrChatWindowInput p {
    margin: 0;
    }
    </style>
    <?php
    if(!isset($_POST['fldrNameInput'])) {
    ?>
    <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
    Name:<input type="text" name="fldrNameInput">
    <input type="submit">
    </form>
    <?php
    } else {
     $fldrName = $_POST['fldrNameInput'];
     $fldrName = mysql_real_escape_string($fldrName);
     $_SESSION['$fldrName'] = $fldrName;
    ?>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script type="text/javascript">
    jQuery(function($){
    	var field1 = $('#fldrChatWindowInput'), 
    	field2 = "";
    	$('#send').click(function(){
    		if(!field1.html()){
    			alert("Please enter a value");
    			field1.focus();
    			return;
    		}
    		jQuery.ajax({
    			url: 'process.php',
    			type: 'post',
    			data: 'field1value=' + field1.html() + '&field2value=' + field2.value,
    			success: function(results){
    				alert(results);
    			}
    		});
    	});
    });
    </script>
    </head>
    <body>
    <div id="fldrChatWindow"></div>
    <div id="fldrChatWindowInput" contenteditable></div>
    <input type="button" value="Submit" id="send">
    <head>
    </head>
    <body>
    </body>
    </html>
    <?php
    }
    } else {
    
    ?>
    
    <?php
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ----
    ?> 
    <html>
    <head>
    <style type="text/css">
    #fldrChatWindow {
    width:<?php echo $fldr_CW_width; ?>;
    height:<?php echo $fldr_CW_height; ?>; 
    background-color:<?php echo $fldr_CW_bgcolor; ?>;  
    border-top:<?php echo $fldr_CW_border_top; ?>;
    border-right:<?php echo $fldr_CW_border_right; ?>;
    border-left:<?php echo $fldr_CW_border_left; ?>;
    border-bottom:<?php echo $fldr_CW_border_bottom; ?>;
    overflow:auto;
    word-wrap:break-word;
    }
    #fldrChatWindowInput {
    width:<?php echo $fldr_CWI_width; ?>;
    height:<?php echo $fldr_CWI_height; ?>; 
    background-color:<?php echo $fldr_CWI_bgcolor; ?>;
    border-top:<?php echo $fldr_CWI_border_top; ?>;
    border-right:<?php echo $fldr_CWI_border_right; ?>;
    border-left:<?php echo $fldr_CWI_border_left; ?>;
    border-bottom:<?php echo $fldr_CWI_border_bottom; ?>;
    overflow:auto;
    word-wrap:break-word;
    }
    #fldrChatWindow p {
    margin: 0;
    }
    #fldrChatWindowInput p {
    margin: 0;
    }
    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script type="text/javascript">
    jQuery(function($){
    	var field1 = $('#fldrChatWindowInput'), 
    	field2 = "";
    	$('#send').click(function(){
    		if(!field1.html()){
    			alert("Please enter a value");
    			field1.focus();
    			return;
    		}
    		jQuery.ajax({
    			url: 'process.php',
    			type: 'post',
    			data: 'field1value=' + field1.html() + '&field2value=' + field2.value,
    			success: function(results){
    				alert(results);
    			}
    		});
    	});
    });
    </script>
    </head>
    <body>
    <div id="fldrChatWindow"></div>
    <div id="fldrChatWindowInput" contenteditable></div>
    <input type="button" value="Submit" id="send">
    <head>
    </head>
    <body>
    </body>
    </html>
    
    <?php
    }
    ?>
    by div windows I mean this bit

    Code:
    <div id="fldrChatWindow"></div>
    <div id="fldrChatWindowInput" contenteditable></div>
    Hope this makes it more clear.
    Keyboard1333

Bookmarks

Posting Permissions

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