Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-06-2009, 03:15 PM Need Help Urgently!!
Banned

Posts: 19
Name: Lewis
Trades: 0
on my website i have a form in the corner to search for people, here it is
Code:
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'searchprofile.tpl', 15, false),)), $this); ?>
<?php echo '<form name="frmQuickSearch" method="get" action="searchmatch.php"><table   cellspacing="2" cellpadding="0" border="0"><tr><td>I am a </td><td>'; ?><?php if ($_SESSION['txtgender']): ?><?php echo ''; ?><?php $this->assign('gender2', $_SESSION['txtgender']); ?><?php echo ''; ?><?php else: ?><?php echo ''; ?><?php $this->assign('gender2', 'M'); ?><?php echo ''; ?><?php endif; ?><?php echo '<select class="searchselect" name="txtgender" style=\'width: 100px\'>'; ?><?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['lang']['signup_gender_values'],'selected' => $_SESSION['txtgender']), $this);?><?php echo '</select></td></tr><tr><td>seeking a </td><td>'; ?><?php if ($_SESSION['txtlookgender']): ?><?php echo ''; ?><?php $this->assign('gender2', $_SESSION['txtlookgender']); ?><?php echo ''; ?><?php else: ?><?php echo ''; ?><?php $this->assign('gender2', 'F'); ?><?php echo ''; ?><?php endif; ?><?php echo '<select class="searchselect" name="txtlookgender" style=\'width: 100px\'>'; ?><?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['lang']['signup_gender_look'],'selected' => $this->_tpl_vars['gender2']), $this);?><?php echo '</select></td></tr><tr><td>who is from </td><td><select class="searchselect" name="txtlookagestart">'; ?><?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['lang']['start_agerange'],'output' => $this->_tpl_vars['lang']['start_agerange'],'selected' => $_SESSION['lookagestart']), $this);?><?php echo '</select> to <select class="searchselect" name="txtlookageend">'; ?><?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['lang']['end_agerange'],'output' => $this->_tpl_vars['lang']['end_agerange'],'selected' => $_SESSION['lookageend']), $this);?><?php echo '</select></td></tr><tr><td colspan="2">who has a photo&nbsp;&nbsp;<input type="checkbox" name="with_photo" value="1" '; ?><?php if ($_SESSION['with_photo'] == '1'): ?><?php echo 'checked="checked"'; ?><?php endif; ?><?php echo ' /></td></tr><tr><td style="text-align:right;" colspan="2"><input type="submit" value="Search" class="formbutton" /></td></tr></table></form>'; ?>
what i want to do is, if they are logged in show the search button so they can search, and if they are not logged in it has a button to redirect to the register page. can anyone help.

so the main editing would be before this,
Code:
<input type="submit" value="Search" class="formbutton"
any help, thanks before hand.
Gamestrolley is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-06-2009, 03:24 PM Re: Need Help Urgently!!
Super Talker

Posts: 115
Name: Not Telling
Trades: 0
I would make if statements, like if there is a logged in session then show this link, and an else, for a long link.
__________________
MY MSN:
Please login or register to view this content. Registration is FREE

PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
PM me anytime for HTML, PHP or web design help. I will be glad to help you out.
sith717 is offline
Reply With Quote
View Public Profile
 
Old 12-06-2009, 04:27 PM Re: Need Help Urgently!!
Banned

Posts: 19
Name: Lewis
Trades: 0
thanks for the reply, i know that from looking all over google, but what would the exact code be? i will add you on msn.
Gamestrolley is offline
Reply With Quote
View Public Profile
 
Old 12-06-2009, 05:03 PM Re: Need Help Urgently!!
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Basically
PHP Code:
<?php
if (isset($_SESSION['username'])) {
   
// Your code
} else {
   
// Redirect button
   
echo '<form action="login.php">'
      
'<input type="submit" value="Login">'
      
'</form>';
}
?>
where 'username' is the name of some session variable you set when people log in. Change it so it fits your code.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 12-07-2009, 02:12 AM Re: Need Help Urgently!!
Banned

Posts: 19
Name: Lewis
Trades: 0
thanks very much, where do i find the session variable's ?
Gamestrolley is offline
Reply With Quote
View Public Profile
 
Old 12-07-2009, 12:50 PM Re: Need Help Urgently!!
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Couldn't tell without looking at your login script. Try to browse through it on your own to find the bit where a user is actually logged in, probably (possibly not) in a function or class method called login(), validate_login() or similar. There should be one or more sessions variables being set, like $_SESSION['username'], $_SESSION['logged_in'] or similar.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 12-08-2009, 02:37 PM Re: Need Help Urgently!!
Banned

Posts: 19
Name: Lewis
Trades: 0
im stuck, could you help me on teamviewer?
Gamestrolley is offline
Reply With Quote
View Public Profile
 
Old 12-08-2009, 02:54 PM Re: Need Help Urgently!!
Banned

Posts: 19
Name: Lewis
Trades: 0
thanks so far, i think i found it.i think it was:
Code:
$_SESSION['UserId']
so would that make it:
Code:
<?php
if (isset($_SESSION['UserId'])) {

<?php /* Smarty version 2.6.18, created on 2009-12-04 20:55:22
         compiled from searchprofile.tpl */ ?>

<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'searchprofile.tpl', 15, false),)), $this); ?>
<?php echo '<form name="frmQuickSearch" method="get" action="searchmatch.php"><table   cellspacing="2" cellpadding="0" border="0"><tr><td>I am a </td><td>'; ?><?php if ($_SESSION['txtgender']): ?><?php echo ''; ?><?php $this->assign('gender2', $_SESSION['txtgender']); ?><?php echo ''; ?><?php else: ?><?php echo ''; ?><?php $this->assign('gender2', 'M'); ?><?php echo ''; ?><?php endif; ?><?php echo '<select class="searchselect" name="txtgender" style=\'width: 100px\'>'; ?><?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['lang']['signup_gender_values'],'selected' => $_SESSION['txtgender']), $this);?><?php echo '</select></td></tr><tr><td>seeking a </td><td>'; ?><?php if ($_SESSION['txtlookgender']): ?><?php echo ''; ?><?php $this->assign('gender2', $_SESSION['txtlookgender']); ?><?php echo ''; ?><?php else: ?><?php echo ''; ?><?php $this->assign('gender2', 'F'); ?><?php echo ''; ?><?php endif; ?><?php echo '<select class="searchselect" name="txtlookgender" style=\'width: 100px\'>'; ?><?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['lang']['signup_gender_look'],'selected' => $this->_tpl_vars['gender2']), $this);?><?php echo '</select></td></tr><tr><td>who is from </td><td><select class="searchselect" name="txtlookagestart">'; ?><?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['lang']['start_agerange'],'output' => $this->_tpl_vars['lang']['start_agerange'],'selected' => $_SESSION['lookagestart']), $this);?><?php echo '</select> to <select class="searchselect" name="txtlookageend">'; ?><?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['lang']['end_agerange'],'output' => $this->_tpl_vars['lang']['end_agerange'],'selected' => $_SESSION['lookageend']), $this);?><?php echo '</select></td></tr><tr><td colspan="2">who has a photo&nbsp;&nbsp;<input type="checkbox" name="with_photo" value="1" '; ?><?php if ($_SESSION['with_photo'] == '1'): ?><?php echo 'checked="checked"'; ?><?php endif; ?><?php echo ' /></td></tr><tr><td style="text-align:right;" colspan="2"><input type="submit" value="Search" class="formbutton" /></td></tr></table></form>'; ?>
} else {
http://www.datingforbikers.co.uk/signup.php
   echo '<form action="login.php">'
      . '<input type="submit" value="Login">'
      . '</form>';
}
?>
there is a error some where in there, because it won't work so far.
Gamestrolley is offline
Reply With Quote
View Public Profile
 
Old 12-08-2009, 03:54 PM Re: Need Help Urgently!!
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
When you get error messages, always post them here, they're there to help. In this case it's because you have a url in the middle of the code, without any echo. Plus, you're trying to open with a php tag (<?php) inside the php code, you dont need to (and can't) open it again. Also, there is no need to close the php tag and directly opening it again, just have it open and do all the things you want, then close it.

Try changing it into this:

PHP Code:
<?php
// If a session is not already started, you need to do so first.
// It probably is already and you can remove this comment, but
// if you get some error message about a session not being started
// just uncomment this next line:

// session_start();

if (isset($_SESSION['UserId'])) {

/* Smarty version 2.6.18, created on 2009-12-04 20:55:22
         compiled from searchprofile.tpl */

require_once(SMARTY_CORE_DIR 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function''html_options''searchprofile.tpl'15false),)), $this);

echo 
'<form name="frmQuickSearch" method="get" action="searchmatch.php"><table   cellspacing="2" cellpadding="0" border="0"><tr><td>I am a </td><td>'?><?php if ($_SESSION['txtgender']): ?><?php echo ''?><?php $this->assign('gender2'$_SESSION['txtgender']); ?><?php echo ''?><?php else: ?><?php echo ''?><?php $this->assign('gender2''M'); ?><?php echo ''?><?php endif; ?><?php echo '<select class="searchselect" name="txtgender" style=\'width: 100px\'>'?><?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['lang']['signup_gender_values'],'selected' => $_SESSION['txtgender']), $this);?><?php echo '</select></td></tr><tr><td>seeking a </td><td>'?><?php if ($_SESSION['txtlookgender']): ?><?php echo ''?><?php $this->assign('gender2'$_SESSION['txtlookgender']); ?><?php echo ''?><?php else: ?><?php echo ''?><?php $this->assign('gender2''F'); ?><?php echo ''?><?php endif; ?><?php echo '<select class="searchselect" name="txtlookgender" style=\'width: 100px\'>'?><?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['lang']['signup_gender_look'],'selected' => $this->_tpl_vars['gender2']), $this);?><?php echo '</select></td></tr><tr><td>who is from </td><td><select class="searchselect" name="txtlookagestart">'?><?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['lang']['start_agerange'],'output' => $this->_tpl_vars['lang']['start_agerange'],'selected' => $_SESSION['lookagestart']), $this);?><?php echo '</select> to <select class="searchselect" name="txtlookageend">'?><?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['lang']['end_agerange'],'output' => $this->_tpl_vars['lang']['end_agerange'],'selected' => $_SESSION['lookageend']), $this);?><?php echo '</select></td></tr><tr><td colspan="2">who has a photo&nbsp;&nbsp;<input type="checkbox" name="with_photo" value="1" '?><?php if ($_SESSION['with_photo'] == '1'): ?><?php echo 'checked="checked"'?><?php endif; ?><?php echo ' /></td></tr><tr><td style="text-align:right;" colspan="2"><input type="submit" value="Search" class="formbutton" /></td></tr></table></form>';
} else {
   
// I'm guessing you want this as a link?
   
echo '<a href="http://www.datingforbikers.co.uk/signup.php">Sign up</a>';
   echo 
'<form action="login.php">'
      
'<input type="submit" value="Login">'
      
'</form>';
}
?>
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 12-08-2009, 05:05 PM Re: Need Help Urgently!!
Banned

Posts: 19
Name: Lewis
Trades: 0
thanks, i can't post the error, because i know there is a error, becaus the page only loads the header.
Gamestrolley is offline
Reply With Quote
View Public Profile
 
Old 12-08-2009, 05:11 PM Re: Need Help Urgently!!
Banned

Posts: 19
Name: Lewis
Trades: 0
Thank you so much, i can't express how happy i am, if i had money i would pay you. added talkutation.
Gamestrolley is offline
Reply With Quote
View Public Profile
 
Old 12-08-2009, 05:19 PM Re: Need Help Urgently!!
Banned

Posts: 19
Name: Lewis
Trades: 0
also how do you, make it say something would it be,
Code:
echo 'to search login or signup'
Gamestrolley is offline
Reply With Quote
View Public Profile
 
Old 12-08-2009, 06:57 PM Re: Need Help Urgently!!
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Yes, echo is used to print stuff to the page. There is also print, which does the exact same thing. A few examples, to explain some basics.

PHP Code:
// will write 'some text'
echo "some text";
echo 
'some text';

$var "some text";
echo 
"The value is: $var"// will write 'The value is: some text'
echo 'The value is: $var'// will write 'The value is: $var'
echo 'The value is: ' $var// will write 'The value is: some text' 
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Need Help Urgently!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.55606 seconds with 12 queries