Some Problem "uid" ,Fatal Error

Ask about a PHP problem here.
Post Reply
almanafi
Posts: 5
Joined: Thu Aug 16, 2012 6:22 pm

Some Problem "uid" ,Fatal Error

Post by almanafi »

hi , everyone

i have many problem in my system
i followed the "Private message tutorial"
but im make the index.php as a login page and when you login,
you will return to profile.php

and i have also a problem in "profile.php" i should write "?uid=2"
----------------------------------
Notice: Undefined index: uid in C:\xampp\htdocs\almanafi\profile.php on line 10
----------------------------------

the big problem in "private message tutorial"

i didnt make url like jacek " index.php?page=new_conversation

i make a new_conversation.php in same folder (almanafi)
so when i click on send i have an error "The list of names you gave does not look valid."

but im shure that the username is right and its on the Database
it have ( - and . and _ )

and when i write a fake simple name fore EXAMPLE "facebook"
i have this error
--------------------------------
Fatal error: Call to undefined function fetch_user_ids() in C:\xampp\htdocs\almanafi\new_conversation.php on line 25
--------------------------------

i dont know how to fix this
and thanks
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Some Problem "uid" ,Fatal Error

Post by jacek »

Can you post your code ? It sounds like you are not using the template system like I did but only removed half of it.
Image
almanafi
Posts: 5
Joined: Thu Aug 16, 2012 6:22 pm

Re: Some Problem "uid" ,Fatal Error

Post by almanafi »

[syntax=php]<?php

session_start();
include ("header.php");
?>
<link rel="stylesheet" type="text/css" href="ext/css/main.css" />

<body>
<div id="wrap">
<?php
if (isset($_POST['to'], $_POST['subject'], $_POST['body'])){
$errors = array();

if (empty($_POST['to'])){
$errors[] = 'You must enter at least one name.';
}else if (preg_match('%^[a-z, ]+$%i', $_POST['to']) === 0){
$errors[] = 'The list of names you gave does not look valid.';
}else{
$usernames = explode(',', $_POST['to']);

foreach ($usernames as &$name){
$name = trim($name);
}

$user_ids = fetch_user_ids($usernames);

if(count($user_ids) !== count($usernames)){
$errors[] = 'The following users could not be found: ' . implode(', ', array_diff($usernames, array_keys($user_ids)));
}

}

if (empty($_POST['subject'])){
$errors[] = 'The subject cannot be empty.';
}

if (empty($_POST['body'])){
$errors[] = 'The body canoot be empty.';
}

if (empty($errors)){
create_conversation(array_unique($user_ids) , $_POST['subject'], $_POST['body']);
}
}

if (isset($errors)){
if (empty($errors)){
echo '<div class="msg success">Your message has been sent ! <a href="inbox.php">Return to inbox</a></div>';
}else{
foreach ($errors as $error){
echo '<div class="msg error">', $error, '</div>';
}
}
}
?>

<form action="" method="post">
<div>
<label for="to">To:</label>
<input type="text" name="to" id="to" value="<?php if (isset($_POST['to'])) echo htmlentities($_POST['to']); ?>"/>
</div>
<div>
<label for="subject">Subject:</label>
<input type="text" name="subject" id="subject" value="<?php if (isset($_POST['subject'])) echo htmlentities($_POST['subject']); ?>" />
</div>
<div>
<textarea name="body" rows="20" cols="95" ><?php if (isset($_POST['body'])) echo htmlentities($_POST['body']); ?></textarea>
</div>
<div>
<input type="submit" value="Send" />
</div>
</form>
</body>
<center>
<?php include ("footer.php"); ?>
</center>[/syntax]

htdocs\almanafi\new_conversation.php
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Some Problem "uid" ,Fatal Error

Post by jacek »

You're not including the init.inc.php file ? That is where the function is defined.
Image
almanafi
Posts: 5
Joined: Thu Aug 16, 2012 6:22 pm

Re: Some Problem "uid" ,Fatal Error

Post by almanafi »

sorry for my late

i have include the init.inc.php file and i have another error
--------------
Fatal error: Call to undefined function create_conversation() in C:\xampp\htdocs\inconnect\new_conversation.php on line 44
--------------
and i try to write a username in To: (textbox) i have this error
(The list of names you gave does not look valid.)
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Some Problem "uid" ,Fatal Error

Post by jacek »

Can you post the code again with the cages you made ? All files would be good :)
Image
Post Reply