O so good! Nice talking. could always use....
$redirectLoc='<meta http-equiv="refresh" content="2;url=index.php">
O so good! Nice talking. could always use....
$redirectLoc='<meta http-equiv="refresh" content="2;url=index.php">
K just been looking at me own login script and realised it's been made in a different way and no use at this time, good luck, happy code, happy day. This may be of use though.. Login.php
<?php
include("dbconnect.php");
// Same checking stuff all over again.
if(isset($_POST['submit'])) {
if(empty($_POST['admin_username']) || empty($_POST['admin_password'])) {
echo "Opps! You have to fill in all forms";
$head_info='<meta http-equiv="refresh" content="2;url=login.php">';
exit;
} // Create the variables again.
$username = $_POST['admin_username']; $password = $_POST['admin_password'];
// Encrypt the password again with the md5 hash.
// This way the password is now the same as the password inside the database.
$password = md5($password);
// Store the SQL query inside a variable.
// ONLY the username you have filled in is retrieved from the database.
$query = "SELECT admin_username, admin_password
FROM admin_login
WHERE admin_username='$username'";
$result = mysql_query($query);
if(!$result) {
// Gives an error if the username given does not exist.
// or if something else is wrong.
echo "Failed " . mysql_error();
} else {
// Now create an object from the data you've retrieved.
$row = mysql_fetch_object($result);
// You've now created an object containing the data.
// You can call data by using -> after $row.
// For example now the password is checked if they're equal.
include("session.php");
echo "login sucessful. Please wait. Redirecting you to our administration page now";
$head_info='<meta http-equiv="refresh" content="2;url=admin.php">';
if($row->password != $password) {
echo "Wrong password.";
$head_info='<meta http-equiv="refresh" content="2;url=login.php">';
exit;
}
}
}
?>
<html>
Session.php
<?php
session_start();
$_SESSION['your_name']=$admin_username;
?>
Hmm o good if your interested?
Might be overly complex os_dev. I've got some easy login script. uses includes -etc..
less variables. Session should always be at the top - no whitespace.
thought some 'if isset and so on could smooth things up'
Nice work though. I'll be coming back to this one :^)
I'm new to this site, don't know if i'm doing right... just asking pls reply. thanks..
Have a look at the home page. You probably should be looking at web design. Then start a new thread. :^)
Ajax/JS would be useful for dynamic update of page (add/edit functions), although not essential.
I've only scanned your code, I'm afraid - long tracts give me a nose-bleed!
You could have a list of posts (headline and bodytext) with a clickable image linked to a js command. This loads a lightbox with a form linked to the post id via hidden field value. The lightbox form is sent to an ajax js function which runs the mysql functions and updates the particular div holding the edited post.
You could also have an 'Add New Post' image which pops up a similar lightbox, but has a value of 'new' in the hidden field. The form is sent to an ajax/js function which adds a new record into the DB and appends a div to the page holding the new info.
The images (add and edit) do not appear if the user is logged out.
Just a thought.
Yea good thought - thanks. A php job just at the moment, but that's a cool thought. :^)
yes, that is what they are for.
Also see checkbox.
good info on HTML is available on w3.
We need to know more about the problem, don't you think?
how can i make once button A is clicked, the functions of button B is still present.
You could use two different forms.
And to preset a button. Use....
<input type="radio" value="Pick Me" checked />
Or what about check boxes. Here is a quote...
"Radio buttons are used when you want to let the visitor select one - and just one - option from a set of alternatives. If more options are to be allowed at the same time you should use
check boxes instead".
post your code here, use code tags
this is text_make.php
<?php
session_start();
if ($_SESSION['uname']){$logged_in ='true'; }
$self = $_SERVER['PHP_SELF'];
include("admin/dbconnect.php");
$id = $_REQUEST['text_id'];
//$id = mysql_insert_id();
$sql2="SELECT * FROM text_boxes WHERE $id = text_id";
mysql_insert_id();
$result=mysql_query($sql2);
if ($result){
$num = mysql_num_rows($result);
if ($num > 0){
$row = mysql_fetch_array($result);
$text2 = $row['text'];
$headline2 = $row['headline'];
// Use \n for newline on all systems
$text2 = preg_replace("/(\r\n|\n|\r)/", "\n", $text2);
// Only allow two newlines in a row.
$text2 = preg_replace("/\n\n+/", "\n\n", $text2);
// Put <p>..</p> around paragraphs
$text2 = preg_replace('/\n?(.+?)(\n\n|\z)/s', "<p>$1</p>", $text2);
// Convert newlines not preceded by </p> to a <br /> tag
$text2 = preg_replace('|(?<!</p>)\s*\n|', "<br />", $text2);
}
}
?>
<html>
<head>
<style>textarea.text_edit{font-family: helvetica; background-color: #000000; color: #ffffff;line-height: 1.5em;}
input.head_edit{font-family: helvetica; background-color: #000000; color: #ffffff;font-size: 1.2em;}
.headline: font-size: 1.5em;</style>
<title>test text</title>
</head>
<body style="font-family: helvetica;">
<p><a href="../admin/logout.php">logout</a></p>
<form action="<?php $PHP_SELF;?>" method="post"><input type="submit" value="Create new text field" name="change_text" id="change_text"></form>
<?php
if ($logged_in == 'true') {
if (isset($_POST['change_text'])){
if (!isset($_POST['submit1'])){?>
<table border="0">
<form action="<?php $self;?>" method="post">
<input type="hidden" name="text_id" value="<?php echo $id;?>"/>
<tr>
<td>New Headline</td>
</tr>
<tr>
<td>
<h4><input type="text" name="headline" class="head_edit" value="<?php echo strip_tags($headline2);?>" /></h4>
</td>
</tr>
<tr>
<td>New Text</td>
</tr>
<tr>
<td>
<textarea rows="10" cols="70" name="text" class="text_edit"><?php
$text2 = preg_replace('/</','
<',$text2);
$text2 = preg_replace('/>/','
>',$text2);
$desc = html_entity_decode(strip_tags($text2));
$desc = preg_replace('/[\n\r\t]/',' ',$desc);
$desc = preg_replace('/ /',' ',$desc);
$text2 = preg_replace('/\r/',' ',$text2);
echo strip_tags($text2);
?></textarea>
</td>
</tr>
<tr><td><input type="submit" id="submit1" name="submit1" value="Add field"></td></tr>
</form>
</tr>
</table>
<?php
}
}
}
if (isset($_POST['submit1'])){echo $text2, $headline2;}
if ($_POST['headline']){
if ($_POST['text']){
include("admin/create_text.php");
} …
a key or primary key is required for anything that is 'auto incremented'
so you can 'unlock' the rest of the table. The field should be called
something like "table_id" and use "auto increment" and be "primary key"
or you will get errors for sure.
I thought that.....
session_start();
Has to be at the very top of every page...
or have a look at...
http://php.net/manual/en/function.session-start.php
so this....
session_start();
echo $_SESSION['uname'];
echo "<br/><a href='three.php'>CLICK</a>";
should come before this....
$nowGmDate = gmdate('r');
header("Last-Modified: ".$nowGmDate); // Right now
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache");
header("Cache-Control: no-cache");
Hello. OK won't post my messy code just yet, but the Problem;
A user can UPDATE a text field consisting of a headline and a text
field. This is posted into a 'text div' below. when logged out, the form and editable fuctions vanish and we have a normal web page.
A user can add a text field
which consists of a 'headline' and a 'text'.
But does not then become editable or viewable, just simply
posts into the msql database.
So. HOW DO I GET THE ID AND THEN EDIT THE ID ON THE SAME PAGE? Happy to send the code to anyone interested in having a go at this.
Also you could put this in the head section of your html page
<script type="text/javascript" src="scripts/ajax.js"></script>
Then make or use a 'scripts' folder. In the 'scripts' folder you'll need this file. Copy and paste the whole file and save it as above 'ajax.js'.
var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for Firefox, Opera, IE7, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = "OK"
document.getElementById('your_id').innerHTML=xmlhttp.responseText;
}
else
{
alert("Problem retrieving data:" + xmlhttp.statusText);
}
}
}
Then to call your new section or 'div'
use div id = 'your_id' you can find it in the above
code and call it whatever you like. id = 'your_id'.
Then call it in your html page like this...
<div class="something" onclick="loadXMLDoc('your_id')" style="cursor: pointer" onMouseOver="style.color='#6b93fa'" onMouseOut="style.color='black'"><br />Read more >></div>
'your_id' is a file named 'your_id.xml' or 'your_id.html' and you can create
in it anything you like. Just leave out html tags for that field and etc..
The 'key' is there to 'unlock' all other fields in the table. It 'auto increments' with a 'unique id' so that records are kept separate and tidy and so that you can access and refer to and update specific records.
As it happens I'm using this to swap fields...
<form action="<?php $PHP_SELF;?>" method="post"><input type="submit" value="Create new text field" name="change_text" id="change_text"></form>
<?php
if ($logged_in == 'true') {
if (isset($_POST['change_text'])){
if (!isset($_POST['submit1'])){?>
and then this...
if (isset($_POST['submit1'])){echo $text2, $headline2;}
if ($_POST['headline']){
if ($_POST['text']){
include("admin/create_text.php");
Notice the initial if ! is set post - very easy very nice.
You could always try styling your 'submit' button with css?!
your php is ending and becoming text here > Logout< you could try this...
<?php if($login_successful == "true") { echo "<a href='http://www.icselect.com/login.php'>"?>Logout</a>
<?php;}
else { echo "<a href='http://www.icselect.com/login.php'> Login</a>"; }?>
And Nav33 is right. give your file a .php extension. Maybe that's all you need to do.
solved!!!!! This could be really useful to someone out there.
Text area displays
So what if I want to type in this area and apply
changes below.
Make a new line and edit my text some more.
text div displays
So what if I want to type in this area and apply
changes below.
Make a new line and edit my text some more.
text area code (it displays literally, so any whitespace in the code will show in the textarea)
<textarea rows="10" cols="70" name="text" class="text_edit"><?php
$text = preg_replace('/</','
<',$text);
$text = preg_replace('/>/','
>',$text);
$desc = html_entity_decode(strip_tags($text));
$desc = preg_replace('/[\n\r\t]/',' ',$desc);
$desc = preg_replace('/ /',' ',$desc);
$text = preg_replace('/\r/',' ',$text);
echo strip_tags($text);
?></textarea>
solved!!!!! This could be really useful to someone out there.
Text area displays
So what if I want to type in this area and apply
changes below.
Make a new line and edit my text some more.
text div displays
So what if I want to type in this area and apply
changes below.
Make a new line and edit my text some more.
text area code (it displays literally, so any whitespace in the code will show in the textarea)
<textarea rows="10" cols="70" name="text" class="text_edit"><?php
$text = preg_replace('/</','
<',$text);
$text = preg_replace('/>/','
>',$text);
$desc = html_entity_decode(strip_tags($text));
$desc = preg_replace('/[\n\r\t]/',' ',$desc);
$desc = preg_replace('/ /',' ',$desc);
$text = preg_replace('/\r/',' ',$text);
echo strip_tags($text);
?></textarea>
op has searched for a literal 1 (number) not for a true boolean
that's true
op might want to try this the meta eqiv = is a much faster and nicer way too, depending on what's
required and if it's a php server self.
<?php if($login_successful == "true") { echo "<a href='http://www.icselect.com/login.php?logout=1'> Logout</a>"; }
else { echo '<meta http-equiv="refresh" content="2;url=login.php">'; }
?>
ok not sure what else you've done. I was thinking of 'true' rather than '1'
what about something like
if ($logged_in == 'true') {?>
The only problem with inserting the <p> tags is that unless there are two blank lines to represent a removed <p> tag then it would be impossible to reverse because how would the computer know where to insert these tags? It is best not to strip them in the first place.
Maybe I forget strip tags and use css
#textarea <p>, <br />,
{
display: none;
}
Good thinking, thanks very much, I'll give it a go in the morning. :^)
I'll try that when I get my eyeballs out from the keyboard. Thanks. :^)
Maybe if you nl2br() it before it goes into the db
if ($_POST['text']) { $text=nl2br($_POST['text']); }
then when you want to echo it
$text = strip_tags($text); echo $text;
That worked fine for me...
But we need a code that will reverse what has been posted
and then selected from and to the database.
The text area posts carrige returns and line breaks to the database
and spits all that into the text div. The tags you suggest I keep are the ones I want to get rid of they will just appear as <p>paragraph</p>.
I'm looking for output - or update to a text field where html tags are output to a textarea just like
this
not like<br />this
I may be barking up the wrong tree but I've done some solid code on this and appreciate your input and output, He He :^) Thanks to date().
Have you got some tables and fields set up
in mysql? With date fields?
$from_date= date(Y,M,D)//or whatever php date function u decide.
$to_date = date(Y,M,D)//or whatever php date, could be today for example.
$from_date = $_REQUEST['day_one'];
$to_date = $_REQUEST['today'];
then you SELECT day one < = $from_date and > = $to_date WHERE this AND so on...
See the date function
on php.net http://nz.php.net/manual/en/function.date.php
By the way, nice function wasn't aware of it.
What's happening is that line breaks and paragraphs
are posted from the text field to the text div as
html tags then echoed and the tags stripped out.
so the text field reads; paragraph,paragraph
and without strip_tags; <p>paragraph</p><p>paragraph</p>
Both ways post to the text div as;
paragraph
paragraph
Which is how I'd like my text field to look and behave.
:^) H
Hey thanks for that but in my text field I still get...
<p><p>WARNING - This email and any attachments may be private & confidential.</p><p>another paragraph etc...<br />another
line break etc....
So I'm trying to get those tags out of the text field and what they do in.
Thanks tho... :^)
Okay I have a textarea that edits a text div.
When the user edits the text and submits,
paragraphs and line breaks are passed to the div.
i.e (not the browser)text div after submit....
'WARNING - This email and any attachments may be private & confidential.
If received in error, please delete and inform us by return email.'
textarea after submit....
'WARNING - This email and any attachments may be private & confidential. If received in error, please delete and inform us by return email.'
So the question is how can I get those paragraphs and breaks stored
and retrieved from a Mysql database, when using strip tags?
snippet that makes html tags for new lines..
$text = $row['text'];
$headline = $row['headline'];
// Use \n for newline on all systems
$text = preg_replace("/(\r\n|\n|\r)/", "\n", $text);
// Only allow two newlines in a row.
$text = preg_replace("/\n\n+/", "\n\n", $text);
// Put <p>..</p> around paragraphs
$text = preg_replace('/\n?(.+?)(\n\n|\z)/s', "<p>$1</p>", $text);
// Convert newlines not preceded by </p> to a <br /> tag
$text = preg_replace('|(?<!</p>)\s*\n|', "<br />", $text);
snippet that echos database info and strips the html
<textarea rows="10" cols="50" name="text">
<?php
echo strip_tags($text);
?>
</textarea>
how the info is updated....
$self = $_SERVER['PHP_SELF'];
if ($_POST['text_id']) { $text_id=$_POST['text_id']; }
if ($_POST['headline']) { $headline=$_POST['headline']; }
if ($_POST['text']) { $text=$_POST['text']; }
$tbl_name = "text_boxes";
$text_id = "27";
if ($logged_in=='true'){
$sql="UPDATE $tbl_name SET headline ='".$headline."', text='".$text."' WHERE text_id = '".$text_id."'";
$result=mysql_query($sql);
Any Ideas? …
unless you've used
INSERT * INTO your_table
and or
<form action="retrieve_file.php"
or something like it, we may be a bit off the track.
H
Oh well nice to see some code in this thread.
Here is some of the same if it is php Mysql you are looking for.
<?php
include ("../includes/dbconnect.php");
$tableName ="your_table";
$this = "this";
$sql="SELECT * FROM $tableName WHERE $this = 'this' ORDER BY first ASC";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
while($rows=mysql_fetch_array($result)){
$result = this that and the other
?>
The SELECT * FROM this that and the other your_table_name is something to look at.
also would be good to know some more about the original question Hope to be useful H
Or This code works well with lots of conditions to meet
$sql = "SELECT * FROM artists_details LEFT JOIN attendance ON attendance.record_id AND attendance.visit_date >= '".$from_date."' AND attendance.visit_date <= '".$to_date."' WHERE artists_details.youth='youth' AND attendance.artist_id=artists_details.artist_id AND artists_details.outreach='outreach'";
//echo $sql;
$result4=mysql_query($sql);
$num_rows_y = mysql_num_rows($result4);
That's a big question, are you using msql? If so I may be able to help.
H