 |
|
|
12-06-2009, 03:15 PM
|
Need Help Urgently!!
|
Posts: 19
Name: Lewis
|
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 <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. 
|
|
|
|
12-06-2009, 03:24 PM
|
Re: Need Help Urgently!!
|
Posts: 115
Name: Not Telling
|
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.
|
|
|
|
12-06-2009, 04:27 PM
|
Re: Need Help Urgently!!
|
Posts: 19
Name: Lewis
|
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. 
|
|
|
|
12-06-2009, 05:03 PM
|
Re: Need Help Urgently!!
|
Posts: 807
Name: Mattias Nordahl
Location: Sweden
|
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.
|
|
|
|
12-07-2009, 02:12 AM
|
Re: Need Help Urgently!!
|
Posts: 19
Name: Lewis
|
thanks very much, where do i find the session variable's ?
|
|
|
|
12-07-2009, 12:50 PM
|
Re: Need Help Urgently!!
|
Posts: 807
Name: Mattias Nordahl
Location: Sweden
|
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.
|
|
|
|
12-08-2009, 02:37 PM
|
Re: Need Help Urgently!!
|
Posts: 19
Name: Lewis
|
im stuck, could you help me on teamviewer?
|
|
|
|
12-08-2009, 02:54 PM
|
Re: Need Help Urgently!!
|
Posts: 19
Name: Lewis
|
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 <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.
|
|
|
|
12-08-2009, 03:54 PM
|
Re: Need Help Urgently!!
|
Posts: 807
Name: Mattias Nordahl
Location: Sweden
|
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', 15, false),)), $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 <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.
|
|
|
|
12-08-2009, 05:05 PM
|
Re: Need Help Urgently!!
|
Posts: 19
Name: Lewis
|
thanks, i can't post the error, because i know there is a error, becaus the page only loads the header.
|
|
|
|
12-08-2009, 05:11 PM
|
Re: Need Help Urgently!!
|
Posts: 19
Name: Lewis
|
Thank you so much, i can't express how happy i am, if i had money i would pay you. added talkutation. 
|
|
|
|
12-08-2009, 05:19 PM
|
Re: Need Help Urgently!!
|
Posts: 19
Name: Lewis
|
also how do you, make it say something would it be,
Code:
echo 'to search login or signup'
|
|
|
|
12-08-2009, 06:57 PM
|
Re: Need Help Urgently!!
|
Posts: 807
Name: Mattias Nordahl
Location: Sweden
|
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.
|
|
|
|
|
« Reply to Need Help Urgently!!
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|