to continue on my original question about step by step registration
a start to create a form with a textfield called "sn", where user put the SN.
Then i call by form action a script called verifysn.php to verify the validity of the SN.
But i got some errors...
first. To pass the SN from my form to the other script i put
<?php session_start(); ?> at the top of my form and i got this error :Notice: A session had already been started - ignoring session_start() in /Applications/MAMP/htdocs/Joomla_1.5.9/components/com_chronocontact/chronocontact.html.php(320) : eval()'d code on line 2
and second error
Notice: Undefined property: stdClass::$plugins in /Applications/MAMP/htdocs/Joomla_1.5.9/components/com_chronocontact/chronocontact.html.php on line 303
How can i turn notice off ?
In joomla configuration in servers options, error rapport are "none"...face-meh-blank
My all form code :
<?php
session_start();
?>
<div class="form_item" ><div class="form_element cf_heading"><h1 class="cf_text" id="null">Activate a tag</h1></div><div class="clear"> </div></div><div class="form_item" ><div class="form_element cf_textbox"><label class="cf_label">Enter your tag number</label><input name="sn" type="text" id="text_1" size="30" maxlength="150" class="cf_inputbox required"></div><div class="clear"> </div></div><div class="form_item" ><div class="form_element cf_button"><input name="undefined" type="submit" value="Submit"></div><div class="clear"> </div></div>Thanks😉
You don't need to start a new session, just save the variable in the current session - or include the verify file into the OnSubmit code.
Try 'Simple' or 'System Default' to suppress the error messages - 'None' doesn't always work . And someone posted the code to modify php.ini just yesterday - use that if these don't work.
Bob
so i tried it :
in After submit if put my code
<?php
if(isset($_POST['sn']) && !empty($_POST['sn'])) {
......
if ($boolint == TRUE AND $booleanchar==TRUE AND $boolpos==TRUE)
{
echo ' true';
$_SESSION['error']="Cool";
}
else
{
echo 'false';
$_SESSION['error']="Wrong format";
}
}else{
$_SESSION['error']="No SN was entered, or wrong format";
}
}
?>
<?php echo '<script language="javascript" type="text/javascript"> window.location.reload()</script>';?>This code is supposed to say if the SN entered by the user is valid, stock the result into a variable 'error' and refresh the page.
To print the error i add
<?php
if(isset($_SESSION['error']) && !empty($_SESSION['error'])) {
echo ' Error : '.$_SESSION['error'];
}
?>
and the end of my HTML form...
but... are many errors
Notice: Undefined property: stdClass::$plugins in /Applications/MAMP/htdocs/Joomla_1.5.9/components/com_chronocontact/chronocontact.php on line 286
Notice: Undefined property: stdClass::$mplugins_order in /Applications/MAMP/htdocs/Joomla_1.5.9/components/com_chronocontact/chronocontact.php on line 287
Notice: Undefined property: stdClass::$plugins in /Applications/MAMP/htdocs/Joomla_1.5.9/components/com_chronocontact/chronocontact.php on line 507
Notice: Undefined property: stdClass::$mplugins_order in /Applications/MAMP/htdocs/Joomla_1.5.9/components/com_chronocontact/chronocontact.php on line 508
plus a
You are not allowed to access this URL
message...the url is "index.php?option=com_chronocontact&task=send&chronoformname=activateSN"
i really dont understand..face-meh-blank
thanks again
Nico
You can't use JavaScript in the OnSubmit code to re-display the form. JavaScript will only work in the browser. To re-show the form from the OnSubmit code you can use
<?php
$post = JRequest::get('post');
showform($post);
$error_found = true;
?>To access session data in Joomla 1.5 you can use this code:
<?php
$session = JFactory::getSession(); // get the session object
$session->set('variable_name'); // set a session variable
$session->get('variable_name'); // get a session variable
?>This is from memory so may be wrong!! More docs in the Joomla Docs sites.The messages you have are PHP Notices (not technically errors). You can probably hide them by setting Error Reporting to 'System Default', 'Simple' or 'None' in your site Global Configuration | Server tab.
Bob
in my form HTML code at the end:
<?php
$session =& JFactory::getSession();
echo ' Error : '.$session->get('error',null)."\n";
?>In my submit button :
<?php
$session =& JFactory::getSession();
$session->set('sn',$_POST['sn']);
$sn=$_POST['sn'];
.....
if ($boolint == TRUE AND $booleanchar==TRUE AND $boolpos==TRUE)
{
echo ' true';
$session->set('error','Cool');
}
else
{
echo 'false';
$session->set('error','Wrong format');
}
}else{
$session->set('error','No SN was entered, or wrong format');
}
And to refresh the form :
<?php
$post = JRequest::get('post');
showform($post);
$error_found = true;
?>what can be wrong ? i used exactly what i saw on different websites...face-meh-blank
Thanks again for your help
Nico
I don't know where you have these code snippets any more . . .
[sendfb][/sendfb]
Bob
Just looking at your code, I think that you can do this using the server side validation box - will reply again in a short while.
Bob
If you structure your code so that it returns a message if and only if there is an error then you can put it into the server-side validation box and it will work automatically for you without having to do anything with session variables or anything else.
<?php
if ( !/*check length */ ) {
return "Length error";
} elseif ( !/* valid code */ ) {
return "Invalid code";
}
?> Bob
