View Full Version : php isset simplify
keyboard
03-01-2012, 03:06 AM
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?
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.
keyboard
03-01-2012, 04:31 AM
Oops, sorry forgot to post my 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
<div id="fldrChatWindow"></div>
<div id="fldrChatWindowInput" contenteditable></div>
Hope this makes it more clear.
Keyboard1333
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.