Menu
Hi,
I have moved my website from one hosting to another, simply copied the files to the ftp, and I realized that one session_start(); is not working.
There is no absolute link, nothing I could see that helps me understand why. The only thing I have is that when I remove the session it works (though the variables are not carried forward), but with the session my page is stocked.
It may be hard with only the above info but if you have an idea it will be very welcomed!
Cheers
Likely culprits are an included file with a newline appended after the closing ?> tag by the FTP client*[/QUOTE]
If your ftp client is altering your files at all then you need to get a new client.[/QUOTE]
Can you clarify on what "not working" means? Do the session variables not get carried over? Does it display an error message (be sure to have error reporting on and set to e_all)? Does another part of the page stop working? Need some more info, otherwise its a needle in a haystack type of problem.[/QUOTE]
[CODE]<form id="request_form" action="../../php/request_order.php" method="post" enctype="multipart/form-data" class="request" >[/CODE]
[CODE]jQuery(document).ready(function(){
jQuery('#request_form').submit(function() {
// Disable the submit button
jQuery('#request_form input[type=submit]')
.attr('value', 'Envoi...')
.attr('disabled', 'disabled');
// AJAX POST request
jQuery.post(
jQuery(this).attr('action'),
{
ref:jQuery('#ref').val(),
domain:jQuery('#domain').val(),
new_domain:jQuery('#new_domain').val(),
name:jQuery('#name').val(),
email:jQuery('#email').val(),
category:jQuery('#category').val(),
image:jQuery('#image').val(),
comment:jQuery('#comment').val()
},
function(errors) {
// No errors
if (errors == null) {
document.location.href="confirmation.php";
}
// Errors
else {
// Re-enable the submit button
jQuery('#request_form input[type=submit]')
.removeAttr('disabled')
.attr('value', 'Envoyer');
// Technical server problem, the email could not be sent
if (errors.server != null) {
alert(errors.server);
return false;
}
// Empty the errorbox and reset the error alerts
jQuery('#request_form .errorbox').html('<ul></ul>').show();
jQuery('#request_form li').removeClass('alert');
// Loop over the errors, mark the corresponding input fields,
// and add the error messages to the errorbox.
for (field in errors) {
if (errors[field] != null) {
jQuery('#' + field).parent('li').addClass('alert');
jQuery('#request_form .errorbox ul').append('<li>' + errors[field] + '</li>');
}
}
}
},
'json'
);
// Prevent non-AJAX form submission
return false;
});
});[/CODE]
[CODE]<?php
// CONFIGURATION --------------------------------------------------------------
// This is the email where the contact mails will be sent to.
$config['recipient'] = '[email protected]';
// This is the subject line for contact emails.
$config['subject'] = 'Order %ref%';
// These are the messages displayed in case of form errors.
$config['errors'] = array
(
'no_name' => 'Veuillez entrer votre nom.',
'no_email' => 'Votre adresse email est requise.',
'invalid_email' => 'Votre adresse email n est pas valide.',
'no_domain' => 'Veuillez entrer le nom de domaine de votre choix.',
);
// END OF CONFIGURATION -------------------------------------------------------
// Ignore non-POST requests
if ( ! $_POST)
exit('Nothing to see here. Please go back to the site.');
// Was this an AJAX request or not?
$ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
// Set the correct HTTP headers
header('Content-Type: text/'.($ajax ? 'plain' : 'html').'; charset=utf-8');
// Extract and trim contactform values
$ref = isset($_POST['ref']) ? trim($_POST['ref']) : '';
$domain = isset($_POST['domain']) ? trim($_POST['domain']) : '';
$new_domain = isset($_POST['new_domain']) ? trim($_POST['new_domain']) : '';
$name = isset($_POST['name']) ? trim($_POST['name']) : '';
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
$category = isset($_POST['category']) ? trim($_POST['category']) : '';
$image = isset($_POST['image']) ? trim($_POST['image']) : '';
// Take care of magic quotes if needed (you really should have them disabled)
set_magic_quotes_runtime(0);
if (get_magic_quotes_gpc())
{
$ref = stripslashes($ref);
$domain = stripslashes($domain);
$new_domain = stripslashes($new_domain);
$name = stripslashes($name);
$email = stripslashes($email);
$comment = stripslashes($comment);
$category = stripslashes($category);
$image = stripslashes($image);
}
// Initialize the errors array which will also be sent back as a JSON object
$errors = NULL;
// Validate domain
if ($domain == '')
{
$errors['domain'] = $config['errors']['no_domain'];
}
// Validate name
if ($name == '' || strpos($name, "r") || strpos($name, "n"))
{
$errors['name'] = $config['errors']['no_name'];
}
// Validate email
if ($email == '')
{
$errors['email'] = $config['errors']['no_email'];
}
elseif ( ! preg_match('/^[-_a-z0-9'+*$^&%=~!?{}]++(?:.[-_a-z0-9'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.]).[a-z]{2,6}|d{1,3}(?:.d{1,3}){3})(?::d++)?$/iD', $email))
{
$errors['email'] = $config['errors']['invalid_email'];
}
// Validation succeeded
if (empty($errors))
{
// Prepare subject line
$subject = str_replace('%ref%', $ref, $config['subject']);
// Set date
$todayis = date("l, F j, Y") ;
// Prepare message
$message = "Date: $todayis
Nom: $name
email: $email
Nom de domaine: $domain
Domaine à réserver: $new_domain
Modele reference: $ref ($category)
Commentaire: $comment";
// Additional mail headers
$headers = 'Content-Type: text/plain; charset=utf-8'."rn";
$headers .= 'From: '.$email;
// Send the mail
if ( ! mail($config['recipient'], $subject, $message, $headers))
{
$errors['server'] = 'Il y a un probleme avec notre serveur, nous en sommes desoles. '.
'Envoyez votre message directement: '.$config['recipient'].' Merci.';
}
}
if ($ajax)
{
// Output the possible errors as a JSON object
echo json_encode($errors);
session_start();
$_SESSION['image'] = $image;
$_SESSION['category'] = $category;
$_SESSION['ref'] = $ref;
$_SESSION['name'] = $name;
$_SESSION['domain'] = $domain;
}
else
{
// Show a simple HTML feedback message in case of non-javascript support
if (empty($errors))
{
header('Location: ../fr/steps/confirmation.php');
session_start();
$_SESSION['image'] = $image;
$_SESSION['category'] = $category;
$_SESSION['ref'] = $ref;
$_SESSION['name'] = $name;
$_SESSION['email'] = $email;
}
else
{
echo '<h1>Oups!</h1>';
echo '<p>Veuillez remplir les champs suivants:</p>';
echo '<ul><li>';
echo implode('</li><li>', $errors);
echo '</li></ul>';
echo '<br><br><a href="javascript:history.back(-1);">Retour</a>';
}
}[/CODE]
echo json_encode($errors);
session_start();
[/quote]
session_start(); should always go at the beginning of scripts to reduce the amount of possible error.
And you are echoing data before starting the session...so I'm not sure how this could've worked on any server.[/QUOTE]
[CODE]<img id="image" src="<?php session_start();
echo $_SESSION['image']; ?> " alt="" style="border: 1px black solid;" width="200"/><br>
<p>
<strong>Categorie:</strong> <span id="detail_category"><?php session_start();
echo $_SESSION['category']; ?></span> <br>
<strong>Référence:</strong> <span id="ref"><?php session_start();
echo $_SESSION['ref']; ?></span><[/CODE]
0.1.9 — BETA 5.27